use of javax.xml.bind.annotation.XmlTransient in project entando-core by entando.
the class JAXBGuiFragment method getGuiFragment.
@XmlTransient
public GuiFragment getGuiFragment() {
GuiFragment guiFragment = new GuiFragment();
guiFragment.setCode(this.getCode());
guiFragment.setWidgetTypeCode(this.getWidgetTypeCode());
guiFragment.setPluginCode(this.getPluginCode());
guiFragment.setGui(this.getGui());
guiFragment.setDefaultGui(this.getDefaultGui());
guiFragment.setLocked(this.isLocked());
return guiFragment;
}
use of javax.xml.bind.annotation.XmlTransient in project zm-mailbox by Zimbra.
the class JaxbInfo method gatherInfo.
private void gatherInfo() {
XmlAccessorType accessorType;
rootElementName = null;
XmlAccessType accessType = null;
XmlRootElement rootE = jaxbClass.getAnnotation(XmlRootElement.class);
if (rootE != null) {
rootElementName = rootE.name();
}
xmlType = jaxbClass.getAnnotation(XmlType.class);
accessorType = jaxbClass.getAnnotation(XmlAccessorType.class);
if (accessorType == null) {
Package pkg = jaxbClass.getPackage();
accessorType = pkg.getAnnotation(XmlAccessorType.class);
}
if (accessorType != null) {
accessType = accessorType.value();
}
if (accessType == null) {
// Default value for JAXB
accessType = XmlAccessType.PUBLIC_MEMBER;
}
Field[] fields = jaxbClass.getDeclaredFields();
for (Field field : fields) {
XmlTransient xmlTransient = field.getAnnotation(XmlTransient.class);
if (xmlTransient != null) {
continue;
}
Annotation[] fAnnots = field.getAnnotations();
if ((fAnnots == null) || (fAnnots.length == 0)) {
boolean autoFields = (accessType.equals(XmlAccessType.PUBLIC_MEMBER) || accessType.equals(XmlAccessType.FIELD));
if (!autoFields) {
continue;
}
}
processFieldRelatedAnnotations(fAnnots, field.getName(), field.getGenericType());
}
Method[] methods = jaxbClass.getDeclaredMethods();
for (Method method : methods) {
XmlTransient xmlTransient = method.getAnnotation(XmlTransient.class);
if (xmlTransient != null) {
continue;
}
if (!isGetterOrSetter(method)) {
continue;
}
Annotation[] mAnnots = method.getAnnotations();
if ((mAnnots == null) || (mAnnots.length == 0)) {
boolean autoGettersSetters = (accessType.equals(XmlAccessType.PUBLIC_MEMBER) || accessType.equals(XmlAccessType.PROPERTY));
if (!autoGettersSetters) {
continue;
}
}
processFieldRelatedAnnotations(mAnnots, guessFieldNameFromGetterOrSetter(method.getName()), method.getGenericReturnType());
}
}
use of javax.xml.bind.annotation.XmlTransient in project tomee by apache.
the class JAXBContextInitializer method isMethodAccepted.
/**
* Checks if the method is accepted as a JAXB property getter.
*/
static boolean isMethodAccepted(Method method, XmlAccessType accessType) {
// We only accept non static property getters which are not marked @XmlTransient
if (Modifier.isStatic(method.getModifiers()) || method.isAnnotationPresent(XmlTransient.class) || !Modifier.isPublic(method.getModifiers()) || "getClass".equals(method.getName())) {
return false;
}
// must not have parameters and return type must not be void
if (method.getReturnType() == Void.class || method.getReturnType() == Void.TYPE || method.getParameterTypes().length != 0 || (method.getDeclaringClass().equals(Throwable.class) && !("getMessage".equals(method.getName()))) || !(method.getName().startsWith("get") || method.getName().startsWith("is"))) {
return false;
}
int beginIndex = 3;
if (method.getName().startsWith("is")) {
beginIndex = 2;
}
Method setter = null;
try {
setter = method.getDeclaringClass().getMethod("set" + method.getName().substring(beginIndex), new Class[] { method.getReturnType() });
} catch (Exception e) {
// getter, but no setter
}
if (setter != null) {
if (setter.isAnnotationPresent(XmlTransient.class) || !Modifier.isPublic(setter.getModifiers())) {
return false;
}
} else if (!Collection.class.isAssignableFrom(method.getReturnType()) && !Throwable.class.isAssignableFrom(method.getDeclaringClass())) {
// not an Exception,
return false;
}
if (accessType == XmlAccessType.NONE || accessType == XmlAccessType.FIELD) {
return checkJaxbAnnotation(method.getAnnotations());
}
return true;
}
Aggregations