@Override public Value mapToValue(Object value) { return new StringValue(((Enum)value).name()); }
/** * Adds a property with a String value * @param propertyName The name of the property * @param stringValue The string value * @return The entity the property has been added to */ @Override public SimpleEntity addProperty(String propertyName, String stringValue) { addValueToProperty(propertyName, new StringValue(stringValue)); return this; }
/** * Adds a property with a String value * @param propertyName The name of the property * @param isCollection True if this is a collection, False if not * @param stringValue The string value * @return The entity the property has been added to */ @Override public SimpleEntity addProperty(String propertyName, boolean isCollection, String stringValue) { addValueToProperty(propertyName, isCollection, new StringValue(stringValue)); return this; }
/** * Adds a property with a colleciton of String values * @param propertyName The name of the property * @param stringValues The string values to add to the property * @return The entity the property has been added to */ @Override public SimpleEntity addProperty(String propertyName, String... stringValues) { for(String value : stringValues) { addValueToProperty(propertyName, new StringValue(value)); } return this; }
@Override public Value mapToValue(Object value) { return new StringValue(mapToRawType(value)); }
/** * Adds a property with a list of String values * @param propertyName The name of the property * @param stringValues The list of string values to add to the property * @return The entity the property has been added to */ @Override public SimpleEntity addProperty(String propertyName, List<String> stringValues) { for(String value : stringValues) { addValueToProperty(propertyName, true, new StringValue(value)); } return this; }
@Override public void setInternalId(String internalId) { this.internalId = internalId; if(properties.containsKey(DOCUMENT_ID)) { removeProperty(DOCUMENT_ID); } addValueToProperty(DOCUMENT_ID, new StringValue(internalId)); }
/** * Allows a bulk set operation of the properties. The properties map contains a key * value pair, the values can be of type {@link java.lang.Integer} , {@link java.lang.Long} * or {@link java.lang.String}. Any unknown types will be called by using the toString operation. * * @param newProperties The properties containing key value pairs * @return The entity the properties have been set on */ @Override public SimpleEntity setProperties(Map<String, Object> newProperties) { this.properties.clear(); for(Map.Entry<String, Object> entry : newProperties.entrySet()) { if(entry.getValue() instanceof Integer) { addValueToProperty(entry.getKey(), new IntegerValue((Integer) entry.getValue())); } else if(entry.getValue() instanceof Long) { addValueToProperty(entry.getKey(), new LongValue((Long) entry.getValue())); } else { addValueToProperty(entry.getKey(), new StringValue(entry.getValue().toString())); } } return this; }