/** * Returns an EntityDataBuilder instance which can be used to construct an entityData from scratch. * @return An instance of EntityDataBuilder. */ public static EntityDataBuilder getBuilder() { return new DefaultEntityDataBuilder(); }
/** * Returns an EntityDataBuilder instance which is partially initialized based on the passed entityData. * This method should be used if you need to construct an entityData starting from an existing entityData. * * For example:- You have an entityData for an entity Customer. But you would like to add an extra element to this entityData for the name of the Customer's company. * The first step you have to do is to get a builder by passing the existing entitydata. * EntityDataBuilder builder = EntityData.getBuilder(customerEntityData); * * Once you have the builder you can add the extra element, by calling the addElement method. * * * @param entityData The entityData from which a new EntityData is to be constructed, for example by adding an extra element. * @return An instance of EntityDataBuilder which is initialized based on the passed EntityData. */ public static EntityDataBuilder getBuilder(EntityData entityData) { return new DefaultEntityDataBuilder(entityData); }
/** * Returns an EntityData instance which is based on a list of properties * * @param propertiesMap List of properties used to construct a new instance of EntityData * @param keys List of key names * @param entityName Name of the newly created entity * @return An instance of EntityData */ public static EntityData createFromMap(Map<String, Object> propertiesMap,List<String> keys,String entityName){ @SuppressWarnings("unchecked") Map<String, Object> cloned = (Map<String, Object>) cloneMap(propertiesMap); DefaultEntityDataBuilder entityDataBuilder = new DefaultEntityDataBuilder(); cloned.forEach((key,value)-> entityDataBuilder.addElement(key,value)); if(keys!=null){ for( String key : keys){ entityDataBuilder.addKeyElement(key,propertiesMap.get(key)); } } return entityDataBuilder.buildEntityData(entityName); }
private static EntityData createFromDeepMap(String serviceName, Map<String, Object> propertiesMap, Map<String, List<String>> keys, String entityName, String associationName) { Map<String, Object> cloned = (Map<String, Object>) cloneMap(propertiesMap); DefaultEntityDataBuilder entityDataBuilder = new DefaultEntityDataBuilder(); cloned.forEach((key,value)-> { if(value instanceof Map) {