/** * Returns a {@link ClassIntrospectorBuilder}-s that could be used to create an identical {@link #ClassIntrospector} * . The returned {@link ClassIntrospectorBuilder} can be modified without interfering with anything. */ ClassIntrospectorBuilder createBuilder() { return new ClassIntrospectorBuilder(this); }
/** * Returns an instance that is possibly shared (singleton). Note that this comes with its own "shared lock", * since everyone who uses this object will have to lock with that common object. */ ClassIntrospector build() { if ((methodAppearanceFineTuner == null || methodAppearanceFineTuner instanceof SingletonCustomizer) && (methodSorter == null || methodSorter instanceof SingletonCustomizer)) { // Instance can be cached. ClassIntrospector instance; synchronized (INSTANCE_CACHE) { Reference instanceRef = (Reference) INSTANCE_CACHE.get(this); instance = instanceRef != null ? (ClassIntrospector) instanceRef.get() : null; if (instance == null) { ClassIntrospectorBuilder thisClone = (ClassIntrospectorBuilder) clone(); // prevent any aliasing issues instance = new ClassIntrospector(thisClone, new Object(), true, true); INSTANCE_CACHE.put(thisClone, new WeakReference(instance, INSTANCE_CACHE_REF_QUEUE)); } } removeClearedReferencesFromInstanceCache(); return instance; } else { // If methodAppearanceFineTuner or methodSorter is specified and isn't marked as a singleton, the // ClassIntrospector can't be shared/cached as those objects could contain a back-reference to the // BeansWrapper. return new ClassIntrospector(this, new Object(), true, false); } }
/** * Two {@link BeansWrapperConfiguration}-s are equal exactly if their classes are identical ({@code ==}), and their * field values are equal. */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BeansWrapperConfiguration other = (BeansWrapperConfiguration) obj; if (!incompatibleImprovements.equals(other.incompatibleImprovements)) return false; if (simpleMapWrapper != other.simpleMapWrapper) return false; if (preferIndexedReadMethod != other.preferIndexedReadMethod) return false; if (defaultDateType != other.defaultDateType) return false; if (outerIdentity != other.outerIdentity) return false; if (strict != other.strict) return false; if (useModelCache != other.useModelCache) return false; if (!classIntrospectorBuilder.equals(other.classIntrospectorBuilder)) return false; return true; }
/** * @param hasSharedInstanceRestrictons * {@code true} exactly if we are creating a new instance with {@link ClassIntrospectorBuilder}. Then * it's {@code true} even if it won't put the instance into the cache. */ ClassIntrospector(ClassIntrospectorBuilder builder, Object sharedLock, boolean hasSharedInstanceRestrictons, boolean shared) { NullArgumentException.check("sharedLock", sharedLock); this.exposureLevel = builder.getExposureLevel(); this.exposeFields = builder.getExposeFields(); this.methodAppearanceFineTuner = builder.getMethodAppearanceFineTuner(); this.methodSorter = builder.getMethodSorter(); this.treatDefaultMethodsAsBeanMembers = builder.getTreatDefaultMethodsAsBeanMembers(); this.bugfixed = builder.isBugfixed(); this.sharedLock = sharedLock; this.hasSharedInstanceRestrictons = hasSharedInstanceRestrictons; this.shared = shared; if (CLASS_CHANGE_NOTIFIER != null) { CLASS_CHANGE_NOTIFIER.subscribe(this); } }
protected Object clone(boolean deepCloneKey) { try { BeansWrapperConfiguration clone = (BeansWrapperConfiguration) super.clone(); if (deepCloneKey) { clone.classIntrospectorBuilder = (ClassIntrospectorBuilder) classIntrospectorBuilder.clone(); } return clone; } catch (CloneNotSupportedException e) { throw new RuntimeException("Failed to clone BeansWrapperConfiguration", e); } }
public boolean getTreatDefaultMethodsAsBeanMembers() { return classIntrospectorBuilder.getTreatDefaultMethodsAsBeanMembers(); }
MethodSorter getMethodSorter() { return classIntrospectorBuilder.getMethodSorter(); }
public MethodAppearanceFineTuner getMethodAppearanceFineTuner() { return classIntrospectorBuilder.getMethodAppearanceFineTuner(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + incompatibleImprovements.hashCode(); result = prime * result + (simpleMapWrapper ? 1231 : 1237); result = prime * result + (preferIndexedReadMethod ? 1231 : 1237); result = prime * result + defaultDateType; result = prime * result + (outerIdentity != null ? outerIdentity.hashCode() : 0); result = prime * result + (strict ? 1231 : 1237); result = prime * result + (useModelCache ? 1231 : 1237); result = prime * result + classIntrospectorBuilder.hashCode(); return result; }
public boolean getExposeFields() { return classIntrospectorBuilder.getExposeFields(); }
public int getExposureLevel() { return classIntrospectorBuilder.getExposureLevel(); }
classIntrospector = _BeansAPI.getClassIntrospectorBuilder(bwConf).build(); sharedIntrospectionLock = classIntrospector.getSharedLock();
/** * @param hasSharedInstanceRestrictons * {@code true} exactly if we are creating a new instance with {@link ClassIntrospectorBuilder}. Then * it's {@code true} even if it won't put the instance into the cache. */ ClassIntrospector(ClassIntrospectorBuilder builder, Object sharedLock, boolean hasSharedInstanceRestrictons, boolean shared) { NullArgumentException.check("sharedLock", sharedLock); this.exposureLevel = builder.getExposureLevel(); this.exposeFields = builder.getExposeFields(); this.methodAppearanceFineTuner = builder.getMethodAppearanceFineTuner(); this.methodSorter = builder.getMethodSorter(); this.treatDefaultMethodsAsBeanMembers = builder.getTreatDefaultMethodsAsBeanMembers(); this.bugfixed = builder.isBugfixed(); this.sharedLock = sharedLock; this.hasSharedInstanceRestrictons = hasSharedInstanceRestrictons; this.shared = shared; if (CLASS_CHANGE_NOTIFIER != null) { CLASS_CHANGE_NOTIFIER.subscribe(this); } }
protected Object clone(boolean deepCloneKey) { try { BeansWrapperConfiguration clone = (BeansWrapperConfiguration) super.clone(); if (deepCloneKey) { clone.classIntrospectorBuilder = (ClassIntrospectorBuilder) classIntrospectorBuilder.clone(); } return clone; } catch (CloneNotSupportedException e) { throw new RuntimeException("Failed to clone BeansWrapperConfiguration", e); } }
public boolean getTreatDefaultMethodsAsBeanMembers() { return classIntrospectorBuilder.getTreatDefaultMethodsAsBeanMembers(); }
MethodSorter getMethodSorter() { return classIntrospectorBuilder.getMethodSorter(); }
public MethodAppearanceFineTuner getMethodAppearanceFineTuner() { return classIntrospectorBuilder.getMethodAppearanceFineTuner(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + incompatibleImprovements.hashCode(); result = prime * result + (simpleMapWrapper ? 1231 : 1237); result = prime * result + (preferIndexedReadMethod ? 1231 : 1237); result = prime * result + defaultDateType; result = prime * result + (outerIdentity != null ? outerIdentity.hashCode() : 0); result = prime * result + (strict ? 1231 : 1237); result = prime * result + (useModelCache ? 1231 : 1237); result = prime * result + classIntrospectorBuilder.hashCode(); return result; }
public boolean getExposeFields() { return classIntrospectorBuilder.getExposeFields(); }
public int getExposureLevel() { return classIntrospectorBuilder.getExposureLevel(); }