Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I have a class with multiple inner class. As part of requirement I need to apply this defaulting to String as Empty when null and For Enumeration when null need to apply default as UNKNOWN. This should be common for all the fields .

You must be logged in to vote

Replies: 1 comment · 2 replies

Comment options

Can you provide a small sample of a nested source and target class so we can have a better understanding of your use case?

You must be logged in to vote
2 replies
@KarthickPari
Comment options

public class SourceBean {

    private FurnitureItem furniture;
    private Shop shop;

    // Getters and Setters Removed for Keeping simple;

}


public class FurnitureItem {

    private String id;
    private String name;
    private FurnitureType type;
    private Material material;
    private Dimensions dimensions;
    private Manufacturer manufacturer;

    // Getters and Setters Removed for Keeping simple;

    public enum FurnitureType {
        CHAIR, TABLE, SOFA, BED, CABINET, UNKNOWN
    }

    public enum Material {
        WOOD, METAL, PLASTIC, GLASS, FABRIC, UNKNOWN
    }

    public static class Dimensions {
        private String height;  
        private String width;
        private String depth;

        // Getters and Setters Removed for Keeping simple;
    
    }

    public static class Manufacturer {
        private String name;
        private Address address;
        private String contactNumber;

        // Getters and Setters Removed for Keeping simple;

        // Nested class inside Manufacturer
        public static class Address {
            private String street;
            private String city;
            private String state;
            private String zipCode;
            private Country country;

            // Getters and Setters Removed for Keeping simple;

            public enum Country {
                INDIA, USA, UK, CANADA, AUSTRALIA, UNKNOWN
            }
        }
    }

    public Manufacturer getManufacturer() { return manufacturer; }
    public void setManufacturer(Manufacturer manufacturer) { this.manufacturer = manufacturer; }
}

public class TargetBean {

    private FurnitureItem furniture;
    private Shop shop;

    // Getters and Setters Removed for Keeping simple;

}
@filiphr
Comment options

@KarthickPari, I edited your comment for formatting. Can you perhaps share what you've tried? How would you write what you are asking for manually?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.