private String getPropertyName(Property property) { return property == null ? "" : property.name(); }
@AutoProperty public class InventoryMutationAction { private String location;
/** * Get the roles specified by a property policy and class policy. * @param elementPolicy the policy on the property ({@code null} if unspecified) * @param classPolicy the policy on the class ({@code null} if unspecified). * @return the roles specified by the policies. * @throws IllegalArgumentException if both {@code elementPolicy} and {@code classPolicy} are * {@code null}. */ public static Set<PropertyRole> getRoles( PojomaticPolicy elementPolicy, DefaultPojomaticPolicy classPolicy) { if (elementPolicy != null) { Set<PropertyRole> roles = elementPolicy.getRoles(); if (roles == null) { // this will be the case for PojomaticPolicy.DEFAULT return classPolicy != null ? classPolicy.getRoles() : PojomaticPolicy.ALL.getRoles(); } else { return roles; } } else if(classPolicy != null) { return classPolicy.getRoles(); } else { return Collections.emptySet(); } } }
private void extractClassProperties( Class<?> clazz, OverridableMethods overridableMethods, ClassContributionTracker classContributionTracker) { AutoProperty autoProperty = clazz.getAnnotation(AutoProperty.class); final DefaultPojomaticPolicy classPolicy = (autoProperty != null) ? autoProperty.policy() : null; final AutoDetectPolicy autoDetectPolicy = (autoProperty != null) ? autoProperty.autoDetect() : null; Map<PropertyRole, Map<String, PropertyElement>> fieldsMap = extractFields( clazz, classPolicy, autoDetectPolicy, classContributionTracker); Map<PropertyRole, Map<String, PropertyElement>> methodsMap = extractMethods( clazz, classPolicy, autoDetectPolicy, overridableMethods, classContributionTracker); if (containsValues(fieldsMap) || containsValues(methodsMap)) { PropertyClassVisitor propertyClassVisitor = PropertyClassVisitor.visitClass(clazz, fieldsMap, methodsMap); if (propertyClassVisitor != null) { for (PropertyRole role: PropertyRole.values()) { properties.get(role).addAll(propertyClassVisitor.getSortedProperties().get(role)); } } else { throw new RuntimeException("no class bytes for " + clazz); } } }
final PojomaticPolicy propertyPolicy = (property != null) ? property.policy() : null;
private static EnhancedPropertyFormatter constructPropertyFormatter(PropertyFormat propertyFormat) throws InstantiationException, IllegalAccessException { if (propertyFormat == null) { return new DefaultEnhancedPropertyFormatter(); } else { if (EnhancedPropertyFormatter.class.isAssignableFrom(propertyFormat.value())) { return (EnhancedPropertyFormatter) propertyFormat.value().newInstance(); } else { @SuppressWarnings("deprecation") EnhancedPropertyFormatterWrapper wrapper = new EnhancedPropertyFormatterWrapper(propertyFormat.value().newInstance()); return wrapper; } } } }
Class<? extends org.pojomatic.formatter.PojoFormatter> pojoFormatterClass = format.value();
@AutoProperty public class ProductOption { private Long productId;
public class PropertyDifferences implements Differences { @Property private final List<Difference> differences;
" is annotated with @Property but either takes arguments or returns void"); propertyPolicy = property.policy();
@XmlRootElement @AutoProperty public class NotesResultContainer { public List<NoteResult> getNoteResult() {
@XmlRootElement @AutoProperty public class NoteResult { private Long noteId;
@XmlRootElement @AutoProperty public class Note { private String userId;
@AutoProperty public class UserRecord {
@XmlRootElement @AutoProperty public class Product { private Long productId;
@AutoProperty public class UserRecord {
@AutoProperty public class CardRequest { @NotNull(message = "tokens required")
@Entity @AutoProperty public class Item implements Serializable {
@AutoProperty public class CardRequest { @NotNull(message = "tokens required")