Search in sources :

Example 6 with SingleKeyHashMap

use of org.codehaus.groovy.util.SingleKeyHashMap in project groovy-core by groovy.

the class MetaClassImpl method inheritFields.

private void inheritFields(LinkedList<CachedClass> superClasses) {
    SingleKeyHashMap last = null;
    for (CachedClass klass : superClasses) {
        SingleKeyHashMap propertyIndex = classPropertyIndex.getNotNull(klass);
        if (last != null) {
            copyNonPrivateFields(last, propertyIndex);
        }
        last = propertyIndex;
        addFields(klass, propertyIndex);
    }
}
Also used : SingleKeyHashMap(org.codehaus.groovy.util.SingleKeyHashMap) CachedClass(org.codehaus.groovy.reflection.CachedClass)

Example 7 with SingleKeyHashMap

use of org.codehaus.groovy.util.SingleKeyHashMap in project groovy-core by groovy.

the class MetaClassImpl method inheritStaticInterfaceFields.

private void inheritStaticInterfaceFields(LinkedList superClasses, Set interfaces) {
    for (Iterator interfaceIter = interfaces.iterator(); interfaceIter.hasNext(); ) {
        CachedClass iclass = (CachedClass) interfaceIter.next();
        SingleKeyHashMap iPropertyIndex = classPropertyIndex.getNotNull(iclass);
        addFields(iclass, iPropertyIndex);
        for (Iterator classIter = superClasses.iterator(); classIter.hasNext(); ) {
            CachedClass sclass = (CachedClass) classIter.next();
            if (!iclass.getTheClass().isAssignableFrom(sclass.getTheClass()))
                continue;
            SingleKeyHashMap sPropertyIndex = classPropertyIndex.getNotNull(sclass);
            copyNonPrivateFields(iPropertyIndex, sPropertyIndex);
        }
    }
}
Also used : SingleKeyHashMap(org.codehaus.groovy.util.SingleKeyHashMap) CachedClass(org.codehaus.groovy.reflection.CachedClass)

Example 8 with SingleKeyHashMap

use of org.codehaus.groovy.util.SingleKeyHashMap in project groovy-core by groovy.

the class MetaClassImpl method copyClassPropertyIndexForSuper.

private void copyClassPropertyIndexForSuper(Index dest) {
    for (ComplexKeyHashMap.EntryIterator iter = classPropertyIndex.getEntrySetIterator(); iter.hasNext(); ) {
        SingleKeyHashMap.Entry entry = (SingleKeyHashMap.Entry) iter.next();
        SingleKeyHashMap newVal = new SingleKeyHashMap();
        dest.put((CachedClass) entry.getKey(), newVal);
    }
}
Also used : SingleKeyHashMap(org.codehaus.groovy.util.SingleKeyHashMap) ComplexKeyHashMap(org.codehaus.groovy.util.ComplexKeyHashMap)

Example 9 with SingleKeyHashMap

use of org.codehaus.groovy.util.SingleKeyHashMap in project groovy by apache.

the class MetaClassImpl method addMetaBeanProperty.

/**
     * Adds a new MetaBeanProperty to this MetaClass
     *
     * @param mp The MetaBeanProperty
     */
public void addMetaBeanProperty(MetaBeanProperty mp) {
    MetaProperty staticProperty = establishStaticMetaProperty(mp);
    if (staticProperty != null) {
        staticPropertyIndex.put(mp.getName(), mp);
    } else {
        SingleKeyHashMap propertyMap = classPropertyIndex.getNotNull(theCachedClass);
        //keep field
        CachedField field;
        MetaProperty old = (MetaProperty) propertyMap.get(mp.getName());
        if (old != null) {
            if (old instanceof MetaBeanProperty) {
                field = ((MetaBeanProperty) old).getField();
            } else if (old instanceof MultipleSetterProperty) {
                field = ((MultipleSetterProperty) old).getField();
            } else {
                field = (CachedField) old;
            }
            mp.setField(field);
        }
        // put it in the list
        // this will overwrite a possible field property
        propertyMap.put(mp.getName(), mp);
    }
}
Also used : SingleKeyHashMap(org.codehaus.groovy.util.SingleKeyHashMap) MultipleSetterProperty(org.codehaus.groovy.runtime.metaclass.MultipleSetterProperty) GetMethodMetaProperty(org.codehaus.groovy.runtime.metaclass.MethodMetaProperty.GetMethodMetaProperty) GetBeanMethodMetaProperty(org.codehaus.groovy.runtime.metaclass.MethodMetaProperty.GetBeanMethodMetaProperty) CachedField(org.codehaus.groovy.reflection.CachedField)

Example 10 with SingleKeyHashMap

use of org.codehaus.groovy.util.SingleKeyHashMap in project groovy by apache.

the class MetaClassImpl method inheritFields.

private void inheritFields(LinkedList<CachedClass> superClasses) {
    SingleKeyHashMap last = null;
    for (CachedClass klass : superClasses) {
        SingleKeyHashMap propertyIndex = classPropertyIndex.getNotNull(klass);
        if (last != null) {
            copyNonPrivateFields(last, propertyIndex, klass);
        }
        last = propertyIndex;
        addFields(klass, propertyIndex);
    }
}
Also used : SingleKeyHashMap(org.codehaus.groovy.util.SingleKeyHashMap) CachedClass(org.codehaus.groovy.reflection.CachedClass)

Aggregations

SingleKeyHashMap (org.codehaus.groovy.util.SingleKeyHashMap)20 CachedClass (org.codehaus.groovy.reflection.CachedClass)10 CachedField (org.codehaus.groovy.reflection.CachedField)8 GetBeanMethodMetaProperty (org.codehaus.groovy.runtime.metaclass.MethodMetaProperty.GetBeanMethodMetaProperty)8 GetMethodMetaProperty (org.codehaus.groovy.runtime.metaclass.MethodMetaProperty.GetMethodMetaProperty)8 ComplexKeyHashMap (org.codehaus.groovy.util.ComplexKeyHashMap)8 GeneratedMetaMethod (org.codehaus.groovy.reflection.GeneratedMetaMethod)4 MultipleSetterProperty (org.codehaus.groovy.runtime.metaclass.MultipleSetterProperty)4 NewInstanceMetaMethod (org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod)4 ClosureMetaMethod (org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod)2 MetaMethodIndex (org.codehaus.groovy.runtime.metaclass.MetaMethodIndex)2 MixinInstanceMetaMethod (org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod)2 NewMetaMethod (org.codehaus.groovy.runtime.metaclass.NewMetaMethod)2 NewStaticMetaMethod (org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod)2 TransformMetaMethod (org.codehaus.groovy.runtime.metaclass.TransformMetaMethod)2