public String getFieldType(SObjectField field) throws MojoExecutionException { // check if this is a picklist if (isPicklist(field)) { // use a pick list enum, which will be created after generating the SObject class return enumTypeName(field.getName()); } else if (isMultiSelectPicklist(field)) { // use a pick list enum array, enum will be created after generating the SObject class return enumTypeName(field.getName()) + "[]"; } else { // map field to Java type final String soapType = field.getSoapType(); final String type = LOOKUP_MAP.get(soapType.substring(soapType.indexOf(':') + 1)); if (type == null) { throw new MojoExecutionException( String.format("Unsupported type %s for field %s", soapType, field.getName())); } return type; } }
public List<PickListValue> getUniqueValues(SObjectField field) { if (field.getPicklistValues().isEmpty()) { return field.getPicklistValues(); } final List<PickListValue> result = new ArrayList<PickListValue>(); final Set<String> literals = new HashSet<String>(); for (PickListValue listValue : field.getPicklistValues()) { final String value = listValue.getValue(); if (!literals.contains(value)) { literals.add(value); result.add(listValue); } } literals.clear(); Collections.sort(result, new Comparator<PickListValue>() { @Override public int compare(PickListValue o1, PickListValue o2) { return o1.getValue().compareTo(o2.getValue()); } }); return result; }
public boolean hasPicklists(SObjectDescription desc) { for (SObjectField field : desc.getFields()) { if (isPicklist(field)) { return true; } } return false; }
public boolean hasMultiSelectPicklists(SObjectDescription desc) { for (SObjectField field : desc.getFields()) { if (isMultiSelectPicklist(field)) { return true; } } return false; }
public boolean isBlobField(SObjectField field) { final String soapType = field.getSoapType(); return BASE64BINARY.equals(soapType.substring(soapType.indexOf(':') + 1)); }
public boolean isMultiSelectPicklist(SObjectField field) { return MULTIPICKLIST.equals(field.getType()); }
public boolean isPicklist(SObjectField field) { // return field.getPicklistValues() != null && !field.getPicklistValues().isEmpty(); return PICKLIST.equals(field.getType()); }