Java Code Examples for org.codehaus.groovy.runtime.MetaClassHelper#sameClasses()

The following examples show how to use org.codehaus.groovy.runtime.MetaClassHelper#sameClasses() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetaClassImpl.java    From groovy with Apache License 2.0 6 votes vote down vote up
public MetaMethod retrieveStaticMethod(String methodName, Object[] arguments) {
    final MetaMethodIndex.Entry e = metaMethodIndex.getMethods(theClass, methodName);
    MetaMethodIndex.CacheEntry cacheEntry;
    if (e != null) {
        cacheEntry = e.cachedStaticMethod;

        if (cacheEntry != null &&
                MetaClassHelper.sameClasses(cacheEntry.params, arguments, e.staticMethods instanceof MetaMethod)) {
            return cacheEntry.method;
        }

        final Class[] classes = MetaClassHelper.convertToTypeArray(arguments);
        cacheEntry = new MetaMethodIndex.CacheEntry(classes, pickStaticMethod(methodName, classes));

        e.cachedStaticMethod = cacheEntry;

        return cacheEntry.method;
    }
    return pickStaticMethod(methodName, MetaClassHelper.convertToTypeArray(arguments));
}
 
Example 2
Source File: MetaClassImpl.java    From groovy with Apache License 2.0 6 votes vote down vote up
private MetaMethod getNormalMethodWithCaching(Object[] arguments, MetaMethodIndex.Entry e) {
    MetaMethodIndex.CacheEntry cacheEntry;
    final Object methods = e.methods;
    if (methods == null)
        return null;

    cacheEntry = e.cachedMethod;

    if (cacheEntry != null &&
            MetaClassHelper.sameClasses(cacheEntry.params, arguments, methods instanceof MetaMethod)) {
        MetaMethod method = cacheEntry.method;
        if (method != null) return method;
    }

    final Class[] classes = MetaClassHelper.convertToTypeArray(arguments);
    cacheEntry = new MetaMethodIndex.CacheEntry(classes, (MetaMethod) chooseMethod(e.name, methods, classes));

    e.cachedMethod = cacheEntry;

    return cacheEntry.method;
}
 
Example 3
Source File: ConstructorMetaMethodSite.java    From groovy with Apache License 2.0 5 votes vote down vote up
public final Object callConstructor(Object receiver, Object[] args) throws Throwable {
    if (receiver == metaClass.getTheClass() // meta class match receiver
       && ((MetaClassImpl)metaClass).getVersion() == version // metaClass still be valid
       && MetaClassHelper.sameClasses(params, args) )  
    {
        MetaClassHelper.unwrap(args);
        try {
            return metaMethod.doMethodInvoke(metaClass.getTheClass(), args);
        } catch (GroovyRuntimeException gre) {
            throw ScriptBytecodeAdapter.unwrap(gre);
        }
    } else {
      return CallSiteArray.defaultCallConstructor(this, receiver, args);
    }
}
 
Example 4
Source File: PojoMetaMethodSite.java    From groovy with Apache License 2.0 5 votes vote down vote up
protected final boolean checkCall(Object receiver, Object[] args) {
    try {
        return receiver.getClass() == metaClass.getTheClass() // meta class match receiver
           && checkPojoMetaClass()
           && MetaClassHelper.sameClasses(params, args);
    }
    catch (NullPointerException e) {
        if (receiver == null)
          return checkCall(NullObject.getNullObject(), args);

        throw e;
    }
}
 
Example 5
Source File: PojoMetaMethodSite.java    From groovy with Apache License 2.0 5 votes vote down vote up
protected final boolean checkCall(Object receiver) {
    try {
        return receiver.getClass() == metaClass.getTheClass() // meta class match receiver
           && checkPojoMetaClass()
           && MetaClassHelper.sameClasses(params);
    } catch (NullPointerException e) {
        if (receiver == null)
          return checkCall(NullObject.getNullObject());

        throw e;
    }
}
 
Example 6
Source File: PojoMetaMethodSite.java    From groovy with Apache License 2.0 5 votes vote down vote up
protected final boolean checkCall(Object receiver, Object arg1) {
    try {
        return receiver.getClass() == metaClass.getTheClass() // meta class match receiver
           && checkPojoMetaClass()
           && MetaClassHelper.sameClasses(params, arg1);
    } catch (NullPointerException e) {
        if (receiver == null)
          return checkCall(NullObject.getNullObject(), arg1);

        throw e;
    }
}
 
Example 7
Source File: PojoMetaMethodSite.java    From groovy with Apache License 2.0 5 votes vote down vote up
protected final boolean checkCall(Object receiver, Object arg1, Object arg2) {
    try {
        return receiver.getClass() == metaClass.getTheClass() // meta class match receiver
           && checkPojoMetaClass()
           && MetaClassHelper.sameClasses(params, arg1, arg2);
    } catch (NullPointerException e) {
        if (receiver == null)
          return checkCall(NullObject.getNullObject(), arg1, arg2);

        throw e;
    }
}
 
Example 8
Source File: PojoMetaMethodSite.java    From groovy with Apache License 2.0 5 votes vote down vote up
protected final boolean checkCall(Object receiver, Object arg1, Object arg2, Object arg3, Object arg4) {
    try {
        return receiver.getClass() == metaClass.getTheClass() // meta class match receiver
           && checkPojoMetaClass()
           && MetaClassHelper.sameClasses(params, arg1, arg2, arg3, arg4);
    } catch (NullPointerException e) {
        if (receiver == null)
          return checkCall(NullObject.getNullObject(), arg1, arg2, arg3, arg4);

        throw e;
    }
}
 
Example 9
Source File: ConstructorSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected final boolean checkCall(Object receiver, Object[] args) {
    return receiver == metaClass.getTheClass() // meta class match receiver
            && ((MetaClassImpl) metaClass).getVersion() == version // metaClass still be valid
            && MetaClassHelper.sameClasses(params, args);
}
 
Example 10
Source File: PogoMetaMethodSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected boolean checkCall(Object receiver, Object arg1, Object arg2, Object arg3, Object arg4) {
    return nonParamCheck(receiver)
            && MetaClassHelper.sameClasses(params, arg1, arg2, arg3, arg4);
}
 
Example 11
Source File: PogoMetaMethodSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected boolean checkCall(Object receiver, Object arg1, Object arg2, Object arg3) {
    return nonParamCheck(receiver)
            && MetaClassHelper.sameClasses(params, arg1, arg2, arg3);
}
 
Example 12
Source File: PogoMetaMethodSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected boolean checkCall(Object receiver, Object arg1, Object arg2) {
    return nonParamCheck(receiver)
            && MetaClassHelper.sameClasses(params, arg1, arg2);
}
 
Example 13
Source File: PogoMetaMethodSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected boolean checkCall(Object receiver, Object arg1) {
    return nonParamCheck(receiver)
            && MetaClassHelper.sameClasses(params, arg1);
}
 
Example 14
Source File: PogoMetaMethodSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected boolean checkCall(Object receiver) {
    return nonParamCheck(receiver)
            && MetaClassHelper.sameClasses(params);
}
 
Example 15
Source File: PogoMetaMethodSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected boolean checkCall(Object receiver, Object[] args) {
    return nonParamCheck(receiver)
            && MetaClassHelper.sameClasses(params, args);
}
 
Example 16
Source File: StaticMetaMethodSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected final boolean checkCall(Object receiver, Object arg1, Object arg2, Object arg3, Object arg4) {
    return receiver == metaClass.getTheClass() // meta class match receiver
       && ((MetaClassImpl)metaClass).getVersion() == version // metaClass still be valid
       && MetaClassHelper.sameClasses(params, arg1, arg2, arg3, arg4);
}
 
Example 17
Source File: StaticMetaMethodSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected final boolean checkCall(Object receiver, Object arg1, Object arg2, Object arg3) {
    return receiver == metaClass.getTheClass() // meta class match receiver
       && ((MetaClassImpl)metaClass).getVersion() == version // metaClass still be valid
       && MetaClassHelper.sameClasses(params, arg1, arg2, arg3);
}
 
Example 18
Source File: StaticMetaMethodSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected final boolean checkCall(Object receiver, Object arg1, Object arg2) {
    return receiver == metaClass.getTheClass() // meta class match receiver
       && ((MetaClassImpl)metaClass).getVersion() == version // metaClass still be valid
       && MetaClassHelper.sameClasses(params, arg1, arg2);
}
 
Example 19
Source File: StaticMetaMethodSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected final boolean checkCall(Object receiver, Object arg1) {
    return receiver == metaClass.getTheClass() // meta class match receiver
       && ((MetaClassImpl)metaClass).getVersion() == version // metaClass still be valid
       && MetaClassHelper.sameClasses(params, arg1);
}
 
Example 20
Source File: StaticMetaMethodSite.java    From groovy with Apache License 2.0 4 votes vote down vote up
protected final boolean checkCall(Object receiver, Object[] args) {
    return receiver == metaClass.getTheClass() // meta class match receiver
       && ((MetaClassImpl)metaClass).getVersion() == version // metaClass still be valid
       && MetaClassHelper.sameClasses(params, args);
}