Method to = mappings[i - 1]; Method from = mappings[i]; descs[--count] = new MethodDesc( to.getName(), to.getParameterTypes(), methodConstraints.getConstraints(from));
check(); } catch (RuntimeException e) { rethrow(e);
/** * Returns a string representation of this object. */ public String toString() { StringBuffer buf = new StringBuffer("BasicMethodConstraints{"); for (int i = 0; i < descs.length; i++) { if (i > 0) { buf.append(", "); } descs[i].toString(buf, true); } buf.append('}'); return buf.toString(); }
Method from = mappings[i - 1]; Method to = mappings[i]; descs[--count] = new MethodDesc( to.getName(), to.getParameterTypes(), methodConstraints.getConstraints(from));
Method from = mappings[i - 1]; Method to = mappings[i]; descs[--count] = new MethodDesc( to.getName(), to.getParameterTypes(), methodConstraints.getConstraints(from));
check(name, types); } catch (RuntimeException e) { rethrow(e);
/** * Creates a descriptor that only matches methods with exactly the specified name and * parameter types. The constraints can be <code>null</code>, which is treated the same as * an empty instance. The array passed to the constructor is neither modified nor retained; * subsequent changes to that array have no effect on the instance created. * * @param name the name of the method * @param types the formal parameter types of the method, in declared order * @param constraints the constraints, or <code>null</code> * @throws NullPointerException if <code>name</code> or <code>types</code> is * <code>null</code> or any element of <code>types</code> * is <code>null</code> * @throws IllegalArgumentException if <code>name</code> is not a syntactically valid method * name */ public MethodDesc(String name, Class[] types, InvocationConstraints constraints) { this.name = name; this.types = types.clone(); if (constraints != null && constraints.isEmpty()) { constraints = null; } this.constraints = constraints; check(); }
/** * Creates a descriptor that matches all methods with names that equal the specified name or * that match the specified pattern, regardless of their parameter types. If the specified * name starts with the character '*', then this descriptor matches all methods with names * that end with the rest of the specified name. If the specified name ends with the * character '*', then this descriptor matches all methods with names that start with the * rest of the specified name. Otherwise, this descriptor matches all methods with names * that equal the specified name. The constraints can be <code>null</code>, which is treated * the same as an empty instance. * * @param name the name of the method, with a prefix or suffix '*' permitted for * pattern matching * @param constraints the constraints, or <code>null</code> * @throws NullPointerException if <code>name</code> is <code>null</code> * @throws IllegalArgumentException if <code>name</code> does not match any syntactically * valid method name */ public MethodDesc(String name, InvocationConstraints constraints) { this.name = name; this.types = null; if (constraints != null && constraints.isEmpty()) { constraints = null; } this.constraints = constraints; check(); }
/** * Creates a descriptor that matches all methods with names that * equal the specified name or that match the specified pattern, * regardless of their parameter types. If the specified name starts * with the character '*', then this descriptor matches all methods * with names that end with the rest of the specified name. If the * specified name ends with the character '*', then this descriptor * matches all methods with names that start with the rest of the * specified name. Otherwise, this descriptor matches all methods * with names that equal the specified name. The constraints can be * <code>null</code>, which is treated the same as an empty instance. * * @param name the name of the method, with a prefix or suffix '*' * permitted for pattern matching * @param constraints the constraints, or <code>null</code> * @throws NullPointerException if <code>name</code> is * <code>null</code> * @throws IllegalArgumentException if <code>name</code> does not * match any syntactically valid method name */ public MethodDesc(String name, InvocationConstraints constraints) { this(check(name, null), name, null, constraints ); }
/** * Creates a descriptor that only matches methods with exactly the * specified name and parameter types. The constraints can be * <code>null</code>, which is treated the same as an empty * instance. The array passed to the constructor is neither modified * nor retained; subsequent changes to that array have no effect on * the instance created. * * @param name the name of the method * @param types the formal parameter types of the method, in declared * order * @param constraints the constraints, or <code>null</code> * @throws NullPointerException if <code>name</code> or * <code>types</code> is <code>null</code> or any element of * <code>types</code> is <code>null</code> * @throws IllegalArgumentException if <code>name</code> is not a * syntactically valid method name */ public MethodDesc(String name, Class[] types, InvocationConstraints constraints) { this(check(name, types), name, types, constraints ); }
/** * Verifies that the method name, parameter types, and constraints are * valid. * * @throws InvalidObjectException if <code>types</code> is * non-<code>null</code> and <code>name</code> is either * <code>null</code> or is not a syntactically valid method name; * or if <code>types</code> is <code>null</code> and <code>name</code> * is neither a syntactically valid method name, a syntactically * valid method name with a '*' appended, nor a name constructed from * some syntactically valid method name containing more than two * characters by replacing the first character of that name with '*'; * or if any element of <code>types</code> is <code>null</code>; or * if <code>constraints</code> is non-<code>null</code> but empty */ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); checkSerial(name, types, constraints); } }
private static StringMethodDesc[] convert(MethodDesc[] descs){ int len = descs.length; StringMethodDesc[] result = new StringMethodDesc[len]; for (int i = 0; i < len; i++){ result [i] = descs[i].getName() != null ? new StringMethodDesc( descs[i].getName(), descs[i].getParameterTypes(), descs[i].getConstraints() ) : new StringMethodDesc(descs[i].getConstraints()); } check(result); return result; }
/** * Returns a string representation of this object. */ public String toString() { StringBuffer buf = new StringBuffer("BasicMethodConstraints{"); for (int i = 0; i < descs.length; i++) { if (i > 0) { buf.append(", "); } descs[i].toString(buf, true); } buf.append('}'); return buf.toString(); }
/** * Throws IllegalArgumentException if the parameter types of prev cover * those of desc. */ private static void check(MethodDesc prev, MethodDesc desc) { if (prev.types == null || Arrays.equals(prev.types, desc.types)) { StringBuffer buf = new StringBuffer(); prev.toString(buf, false); buf.append(" cannot precede "); desc.toString(buf, false); throw new IllegalArgumentException(buf.toString()); } }
/** * Throws IllegalArgumentException if the parameter types of prev cover those of desc. */ private static void check(MethodDesc prev, MethodDesc desc) { if (prev.types == null || Arrays.equals(prev.types, desc.types)) { StringBuffer buf = new StringBuffer(); prev.toString(buf, false); buf.append(" cannot precede "); desc.toString(buf, false); throw new IllegalArgumentException(buf.toString()); } }
/** * Creates an instance that maps all methods to the specified constraints. The constraints can * be <code>null</code>, which is treated the same as an empty instance. Calling this * constructor is equivalent to constructing an instance of this class with an array containing * a single default descriptor constructed with the specified constraints. * * @param constraints the constraints, or <code>null</code> */ public BasicMethodConstraints(InvocationConstraints constraints) { descs = new MethodDesc[]{new MethodDesc(constraints)}; }
/** * Returns a string representation of this object. */ public String toString() { StringBuffer buf = new StringBuffer("MethodDesc["); toString(buf, true); buf.append(']'); return buf.toString(); }
/** * Returns a string representation of this object. */ public String toString() { StringBuffer buf = new StringBuffer("MethodDesc["); toString(buf, true); buf.append(']'); return buf.toString(); }
public MethodDesc(GetArg arg) throws IOException, ClassNotFoundException{ this(checkSerial( arg.get("name", null, String.class), arg.get("types", null, Class[].class), arg.get("constraints", null, InvocationConstraints.class) ), (String) arg.get("name", null), (Class[]) arg.get("types", null), (InvocationConstraints) arg.get("constraints", null) ); }
/** * Creates an instance that maps all methods to the specified constraints. * The constraints can be <code>null</code>, which is treated the same as * an empty instance. Calling this constructor is equivalent to * constructing an instance of this class with an array containing a * single default descriptor constructed with the specified constraints. * * @param constraints the constraints, or <code>null</code> */ public BasicMethodConstraints(InvocationConstraints constraints) { descs = new MethodDesc[]{new MethodDesc(constraints)}; }