Skip to content

Commit

Permalink
bit of renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 11, 2017
1 parent a739500 commit 1c33b0b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected Annotated() { }

protected abstract int getModifiers();

public final boolean isPublic() {
public boolean isPublic() {
return Modifier.isPublic(getModifiers());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public final class AnnotatedClass
*/
final protected Annotations _classAnnotations;

/**
* @since 2.9
*/
protected Creators _creators;

/**
Expand Down Expand Up @@ -241,30 +244,38 @@ public boolean hasAnnotations() {
return _classAnnotations.size() > 0;
}

public AnnotatedConstructor getDefaultConstructor()
{
if (_creators == null) {
_creators = AnnotatedCreatorResolver.resolve(this, _type);
}
return _creators.defaultConstructor;
public AnnotatedConstructor getDefaultConstructor() {
return _creators().defaultConstructor;
}

public List<AnnotatedConstructor> getConstructors()
{
if (_creators == null) {
_creators = AnnotatedCreatorResolver.resolve(this, _type);
}
return _creators.constructors;
public List<AnnotatedConstructor> getConstructors() {
return _creators().constructors;
}

public List<AnnotatedMethod> getStaticMethods()
{
if (_creators == null) {
_creators = AnnotatedCreatorResolver.resolve(this, _type);
}
return _creators.creatorMethods;
/**
* @since 2.9
*/
public List<AnnotatedMethod> getFactoryMethods() {
return _creators().creatorMethods;
}

/**
* @deprecated Since 2.9; use {@link #getFactoryMethods} instead.
*/
@Deprecated
public List<AnnotatedMethod> getStaticMethods() {
return getFactoryMethods();
}

private final Creators _creators() {
Creators c = _creators;
if (c == null) {
_creators = c = AnnotatedCreatorCollector.collectCreators(this, _annotationIntrospector,
_type, _primaryMixIn);
}
return c;
}

public Iterable<AnnotatedMethod> memberMethods()
{
if (_memberMethods == null) {
Expand Down Expand Up @@ -609,7 +620,7 @@ static AnnotationMap[] _emptyAnnotationMaps(int count) {
/**********************************************************
*/

protected boolean _isIncludableMemberMethod(Method m)
private boolean _isIncludableMemberMethod(Method m)
{
if (Modifier.isStatic(m.getModifiers())) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
*
* @since 2.9
*/
final class AnnotatedCreatorResolver
final class AnnotatedCreatorCollector
{
private final static AnnotationMap[] NO_ANNOTATION_MAPS = new AnnotationMap[0];
private final static Annotation[] NO_ANNOTATIONS = new Annotation[0];

// // // Configuration

private final AnnotationIntrospector _intr;
private final TypeResolutionContext _typeContext;
private final AnnotationIntrospector _intr;
private final Class<?> _primaryMixIn;

// // // Collected state
Expand All @@ -39,25 +39,26 @@ final class AnnotatedCreatorResolver
private List<AnnotatedConstructor> _constructors;
private List<AnnotatedMethod> _factories;

public AnnotatedCreatorResolver(AnnotatedClass parent)
AnnotatedCreatorCollector(TypeResolutionContext tc, AnnotationIntrospector intr,
Class<?> mixin)
{
_intr = parent._annotationIntrospector;
_typeContext = parent;
_typeContext = tc;
_intr = intr;
// No point in checking mix-ins if annotation handling disabled:
if (_intr == null) {
if (intr == null) {
_primaryMixIn = null;
} else {
_primaryMixIn = parent._primaryMixIn;
_primaryMixIn = mixin;
}
}

public static Creators resolve(AnnotatedClass parent, JavaType type) {
public static Creators collectCreators(TypeResolutionContext tc, AnnotationIntrospector intr,
JavaType type, Class<?> mixin) {
// Constructor also always members of resolved class, parent == resolution context
return new AnnotatedCreatorResolver(parent).resolve(type, parent);
return new AnnotatedCreatorCollector(tc, intr, mixin).collect(type);
}


public Creators resolve(JavaType type, TypeResolutionContext typeContext)
Creators collect(JavaType type)
{
// 30-Apr-2016, tatu: [databind#1215]: Actually, while true, this does
// NOT apply to context since sub-class may have type bindings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public Map<String,AnnotatedMember> findBackReferenceProperties()
public List<AnnotatedMethod> getFactoryMethods()
{
// must filter out anything that clearly is not a factory method
List<AnnotatedMethod> candidates = _classInfo.getStaticMethods();
List<AnnotatedMethod> candidates = _classInfo.getFactoryMethods();
if (candidates.isEmpty()) {
return candidates;
}
Expand Down Expand Up @@ -566,7 +566,7 @@ public Constructor<?> findSingleArgConstructor(Class<?>... argTypes)
public Method findFactoryMethod(Class<?>... expArgTypes)
{
// So, of all single-arg static methods:
for (AnnotatedMethod am : _classInfo.getStaticMethods()) {
for (AnnotatedMethod am : _classInfo.getFactoryMethods()) {
// 24-Oct-2016, tatu: Better ensure it only takes 1 arg, no matter what
if (isFactoryMethod(am) && am.getParameterCount() == 1) {
// And must take one of expected arg types (or supertype)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
_addCreatorParam(props, ctor.getParameter(i));
}
}
for (AnnotatedMethod factory : _classDef.getStaticMethods()) {
for (AnnotatedMethod factory : _classDef.getFactoryMethods()) {
if (_creatorProperties == null) {
_creatorProperties = new LinkedList<POJOPropertyBuilder>();
}
Expand Down

0 comments on commit 1c33b0b

Please sign in to comment.