List of usage examples for com.google.gwt.core.ext.typeinfo JConstructor isPublic
boolean isPublic();
From source file:com.artemis.gwtref.gen.ReflectionCacheSourceCreator.java
License:Apache License
private static boolean isInstantiableWithNewOperator(JClassType t) { if (!t.isDefaultInstantiable() || t instanceof JArrayType || t instanceof JEnumType) return false; try {//from ww w . ja v a 2 s . c o m JConstructor constructor = t.getConstructor(new JType[0]); return constructor != null && constructor.isPublic(); } catch (NotFoundException e) { return false; } }
From source file:com.github.ludorival.dao.gwt.rebind.EntityManagerGenerator.java
License:Apache License
private boolean isInstantiable(JClassType type, TreeLogger logger) { JConstructor[] constructors = type.getConstructors(); if (constructors == null || constructors.length == 0) return true; JConstructor constructor = type.findConstructor(new JType[0]); if (constructor == null) return false; if (constructor.isPublic()) return true; return false; }
From source file:com.github.nmorel.gwtjackson.rebind.RebindConfiguration.java
License:Apache License
/** * Search a static method or constructor to instantiate the mapper and return a {@link String} calling it. *//*w ww .j a v a 2 s . c o m*/ private MapperInstance getInstance(JType mappedType, JClassType classType, boolean isSerializers) { int nbParam = 0; if (null != mappedType.isGenericType() && (!isSerializers || !typeOracle.isEnumSupertype(mappedType))) { nbParam = mappedType.isGenericType().getTypeParameters().length; } // we first look at static method for (JMethod method : classType.getMethods()) { // method must be public static, return the instance type and take no parameters if (method.isStatic() && null != method.getReturnType().isClassOrInterface() && classType.isAssignableTo(method.getReturnType().isClassOrInterface()) && method.getParameters().length == nbParam && method.isPublic()) { MapperType[] parameters = getParameters(mappedType, method, isSerializers); if (null == parameters) { continue; } return new MapperInstance(classType, method, parameters); } } // then we search the default constructor for (JConstructor constructor : classType.getConstructors()) { if (constructor.isPublic() && constructor.getParameters().length == nbParam) { MapperType[] parameters = getParameters(mappedType, constructor, isSerializers); if (null == parameters) { continue; } return new MapperInstance(classType, constructor, parameters); } } logger.log(Type.WARN, "Cannot instantiate the custom serializer/deserializer " + classType.getQualifiedSourceName() + ". It will be ignored"); return null; }
From source file:com.github.nmorel.gwtjackson.rebind.RebindConfiguration.java
License:Apache License
/** * Search a static method or constructor to instantiate the key mapper and return a {@link String} calling it. */// w w w . jav a 2s .c o m private MapperInstance getKeyInstance(JType mappedType, JClassType classType, boolean isSerializers) { int nbParam = 0; if (!isSerializers && typeOracle.isEnumSupertype(mappedType)) { nbParam = 1; } // we first look at static method for (JMethod method : classType.getMethods()) { // method must be public static, return the instance type and take no parameters if (method.isStatic() && null != method.getReturnType().isClassOrInterface() && classType.isAssignableTo(method.getReturnType().isClassOrInterface()) && method.getParameters().length == nbParam && method.isPublic()) { MapperType[] parameters = getParameters(mappedType, method, isSerializers); if (null == parameters) { continue; } return new MapperInstance(classType, method, parameters); } } // then we search the default constructor for (JConstructor constructor : classType.getConstructors()) { if (constructor.isPublic() && constructor.getParameters().length == nbParam) { MapperType[] parameters = getParameters(mappedType, constructor, isSerializers); if (null == parameters) { continue; } return new MapperInstance(classType, constructor, parameters); } } logger.log(Type.WARN, "Cannot instantiate the custom key serializer/deserializer " + classType.getQualifiedSourceName() + ". It will be ignored"); return null; }
From source file:com.gwtent.gen.GenUtils.java
License:Apache License
public static boolean hasPublicDefaultConstructor(JClassType classType) { for (JConstructor constructor : classType.getConstructors()) { if ((constructor.getParameters().length == 0) && constructor.isPublic()) return true; }//w w w . ja va2s . c o m return false; }
From source file:rocket.generator.rebind.gwt.JConstructorConstructorAdapter.java
License:Apache License
protected Visibility createVisibility() { Visibility visibility = null; while (true) { final JConstructor method = this.getJConstructor(); if (method.isPrivate()) { visibility = Visibility.PRIVATE; break; }/* w w w . jav a 2 s .com*/ if (method.isDefaultAccess()) { visibility = Visibility.PACKAGE_PRIVATE; break; } if (method.isProtected()) { visibility = Visibility.PROTECTED; break; } if (method.isPublic()) { visibility = Visibility.PUBLIC; break; } Checker.fail("Unknown visibility for field " + method); } return visibility; }