/** * This is used to determine if a map contains a primitive key. * A primitive key is a key for a <code>Map</code> that is of * a primitive type and thus can be used as an attribute. Here * we accept all primitive types and also enumerations. * * @param dependents these are the dependents of the map * * @return this returns true if the key is a primitive type */ private boolean isPrimitiveKey(Class[] dependents) { if(dependents != null && dependents.length > 0) { Class parent = dependents[0].getSuperclass(); Class type = dependents[0]; if(parent != null) { if(parent.isEnum()) { return true; } if(type.isEnum()) { return true; } } return isPrimitive(type); } return false; }
/** * This is used to determine if a map contains a primitive key. * A primitive key is a key for a <code>Map</code> that is of * a primitive type and thus can be used as an attribute. Here * we accept all primitive types and also enumerations. * * @param dependents these are the dependents of the map * * @return this returns true if the key is a primitive type */ private boolean isPrimitiveKey(Class[] dependents) { if(dependents != null && dependents.length > 0) { Class parent = dependents[0].getSuperclass(); Class type = dependents[0]; if(parent != null) { if(parent.isEnum()) { return true; } if(type.isEnum()) { return true; } } return isPrimitive(type); } return false; }
/** * This is used to determine if a map contains a primitive key. * A primitive key is a key for a <code>Map</code> that is of * a primitive type and thus can be used as an attribute. Here * we accept all primitive types and also enumerations. * * @param dependents these are the dependents of the map * * @return this returns true if the key is a primitive type */ private boolean isPrimitiveKey(Class[] dependents) { if(dependents != null && dependents.length > 0) { Class parent = dependents[0].getSuperclass(); Class type = dependents[0]; if(parent != null) { if(parent.isEnum()) { return true; } if(type.isEnum()) { return true; } } return isPrimitive(type); } return false; }
/** * This is used to create an annotation for the provided type. * Annotations created are used to match the type provided. So * an array of objects will have an <code>ElementArray</code> * annotation for example. Matching the annotation to the * type ensures the best serialization for that type. * * @param type the type to create the annotation for * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(Class type) throws Exception { ClassLoader loader = getClassLoader(); Class entry = type.getComponentType(); if(type.isArray()) { if(isPrimitive(entry)) { return getInstance(loader, Element.class); } return getInstance(loader, ElementArray.class); } if(isPrimitive(type) && isAttribute()) { return getInstance(loader, Attribute.class); } return getInstance(loader, Element.class); }
/** * This is used to create an annotation for the provided type. * Annotations created are used to match the type provided. So * an array of objects will have an <code>ElementArray</code> * annotation for example. Matching the annotation to the * type ensures the best serialization for that type. * * @param type the type to create the annotation for * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(Class type) throws Exception { ClassLoader loader = getClassLoader(); Class entry = type.getComponentType(); if(type.isArray()) { if(isPrimitive(entry)) { return getInstance(loader, Element.class); } return getInstance(loader, ElementArray.class); } if(isPrimitive(type) && isAttribute()) { return getInstance(loader, Attribute.class); } return getInstance(loader, Element.class); }
/** * This is used to create an annotation for the provided type. * Annotations created are used to match the type provided. So * an array of objects will have an <code>ElementArray</code> * annotation for example. Matching the annotation to the * type ensures the best serialization for that type. * * @param type the type to create the annotation for * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(Class type) throws Exception { ClassLoader loader = getClassLoader(); Class entry = type.getComponentType(); if(type.isArray()) { if(isPrimitive(entry)) { return getInstance(loader, Element.class); } return getInstance(loader, ElementArray.class); } if(isPrimitive(type) && isAttribute()) { return getInstance(loader, Attribute.class); } return getInstance(loader, Element.class); }