private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) { List<CacheParameterDetail> result = new ArrayList<>(); for (int i = 0; i < method.getParameterCount(); i++) { CacheParameterDetail detail = new CacheParameterDetail(method, i); result.add(detail); } return result; }
/** * Return the {@link CacheInvocationParameter} for the parameters that are to be * used to compute the key. * <p>Per the spec, if some method parameters are annotated with * {@link javax.cache.annotation.CacheKey}, only those parameters should be part * of the key. If none are annotated, all parameters except the parameter annotated * with {@link javax.cache.annotation.CacheValue} should be part of the key. * <p>The method arguments must match the signature of the related method invocation * @param values the parameters value for a particular invocation * @return the {@link CacheInvocationParameter} instances for the parameters to be * used to compute the key */ public CacheInvocationParameter[] getKeyParameters(Object... values) { List<CacheInvocationParameter> result = new ArrayList<>(); for (CacheParameterDetail keyParameterDetail : this.keyParameterDetails) { int parameterPosition = keyParameterDetail.getParameterPosition(); if (parameterPosition >= values.length) { throw new IllegalStateException("Values mismatch, key parameter at position " + parameterPosition + " cannot be matched against " + values.length + " value(s)"); } result.add(keyParameterDetail.toCacheInvocationParameter(values[parameterPosition])); } return result.toArray(new CacheInvocationParameter[0]); }
private static List<CacheParameterDetail> initializeKeyParameterDetails(List<CacheParameterDetail> allParameters) { List<CacheParameterDetail> all = new ArrayList<>(); List<CacheParameterDetail> annotated = new ArrayList<>(); for (CacheParameterDetail allParameter : allParameters) { if (!allParameter.isValue()) { all.add(allParameter); } if (allParameter.isKey()) { annotated.add(allParameter); } } return (annotated.isEmpty() ? all : annotated); }
/** * Return the {@link CacheInvocationParameter} for the parameters that are to be * used to compute the key. * <p>Per the spec, if some method parameters are annotated with * {@link javax.cache.annotation.CacheKey}, only those parameters should be part * of the key. If none are annotated, all parameters except the parameter annotated * with {@link javax.cache.annotation.CacheValue} should be part of the key. * <p>The method arguments must match the signature of the related method invocation * @param values the parameters value for a particular invocation * @return the {@link CacheInvocationParameter} instances for the parameters to be * used to compute the key */ public CacheInvocationParameter[] getKeyParameters(Object... values) { List<CacheInvocationParameter> result = new ArrayList<CacheInvocationParameter>(); for (CacheParameterDetail keyParameterDetail : this.keyParameterDetails) { int parameterPosition = keyParameterDetail.getParameterPosition(); if (parameterPosition >= values.length) { throw new IllegalStateException("Values mismatch, key parameter at position " + parameterPosition + " cannot be matched against " + values.length + " value(s)"); } result.add(keyParameterDetail.toCacheInvocationParameter(values[parameterPosition])); } return result.toArray(new CacheInvocationParameter[result.size()]); }
/** * Return the {@link CacheInvocationParameter} for the parameter holding the value * to cache. * <p>The method arguments must match the signature of the related method invocation * @param values the parameters value for a particular invocation * @return the {@link CacheInvocationParameter} instance for the value parameter */ public CacheInvocationParameter getValueParameter(Object... values) { int parameterPosition = this.valueParameterDetail.getParameterPosition(); if (parameterPosition >= values.length) { throw new IllegalStateException("Values mismatch, value parameter at position " + parameterPosition + " cannot be matched against " + values.length + " value(s)"); } return this.valueParameterDetail.toCacheInvocationParameter(values[parameterPosition]); }
private static CacheParameterDetail initializeValueParameterDetail( Method method, List<CacheParameterDetail> allParameters) { CacheParameterDetail result = null; for (CacheParameterDetail parameter : allParameters) { if (parameter.isValue()) { if (result == null) { result = parameter; } else { throw new IllegalArgumentException("More than one @CacheValue found on " + method + ""); } } } return result; }
private static List<CacheParameterDetail> initializeKeyParameterDetails(List<CacheParameterDetail> allParameters) { List<CacheParameterDetail> all = new ArrayList<CacheParameterDetail>(); List<CacheParameterDetail> annotated = new ArrayList<CacheParameterDetail>(); for (CacheParameterDetail allParameter : allParameters) { if (!allParameter.isValue()) { all.add(allParameter); } if (allParameter.isKey()) { annotated.add(allParameter); } } return (annotated.isEmpty() ? all : annotated); }
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) { List<CacheParameterDetail> result = new ArrayList<CacheParameterDetail>(); for (int i = 0; i < method.getParameterTypes().length; i++) { CacheParameterDetail detail = new CacheParameterDetail(method, i); result.add(detail); } return result; }
@Override public CacheInvocationParameter[] getAllParameters(Object... values) { if (this.allParameterDetails.size() != values.length) { throw new IllegalStateException("Values mismatch, operation has " + this.allParameterDetails.size() + " parameter(s) but got " + values.length + " value(s)"); } List<CacheInvocationParameter> result = new ArrayList<CacheInvocationParameter>(); for (int i = 0; i < this.allParameterDetails.size(); i++) { result.add(this.allParameterDetails.get(i).toCacheInvocationParameter(values[i])); } return result.toArray(new CacheInvocationParameter[result.size()]); }
/** * Return the {@link CacheInvocationParameter} for the parameters that are to be * used to compute the key. * <p>Per the spec, if some method parameters are annotated with * {@link javax.cache.annotation.CacheKey}, only those parameters should be part * of the key. If none are annotated, all parameters except the parameter annotated * with {@link javax.cache.annotation.CacheValue} should be part of the key. * <p>The method arguments must match the signature of the related method invocation * @param values the parameters value for a particular invocation * @return the {@link CacheInvocationParameter} instances for the parameters to be * used to compute the key */ public CacheInvocationParameter[] getKeyParameters(Object... values) { List<CacheInvocationParameter> result = new ArrayList<>(); for (CacheParameterDetail keyParameterDetail : this.keyParameterDetails) { int parameterPosition = keyParameterDetail.getParameterPosition(); if (parameterPosition >= values.length) { throw new IllegalStateException("Values mismatch, key parameter at position " + parameterPosition + " cannot be matched against " + values.length + " value(s)"); } result.add(keyParameterDetail.toCacheInvocationParameter(values[parameterPosition])); } return result.toArray(new CacheInvocationParameter[0]); }
@Nullable private static CacheParameterDetail initializeValueParameterDetail( Method method, List<CacheParameterDetail> allParameters) { CacheParameterDetail result = null; for (CacheParameterDetail parameter : allParameters) { if (parameter.isValue()) { if (result == null) { result = parameter; } else { throw new IllegalArgumentException("More than one @CacheValue found on " + method + ""); } } } return result; }
/** * Return the {@link CacheInvocationParameter} for the parameter holding the value * to cache. * <p>The method arguments must match the signature of the related method invocation * @param values the parameters value for a particular invocation * @return the {@link CacheInvocationParameter} instance for the value parameter */ public CacheInvocationParameter getValueParameter(Object... values) { int parameterPosition = this.valueParameterDetail.getParameterPosition(); if (parameterPosition >= values.length) { throw new IllegalStateException("Values mismatch, value parameter at position " + parameterPosition + " cannot be matched against " + values.length + " value(s)"); } return this.valueParameterDetail.toCacheInvocationParameter(values[parameterPosition]); }
@Override public CacheInvocationParameter[] getAllParameters(Object... values) { if (this.allParameterDetails.size() != values.length) { throw new IllegalStateException("Values mismatch, operation has " + this.allParameterDetails.size() + " parameter(s) but got " + values.length + " value(s)"); } List<CacheInvocationParameter> result = new ArrayList<>(); for (int i = 0; i < this.allParameterDetails.size(); i++) { result.add(this.allParameterDetails.get(i).toCacheInvocationParameter(values[i])); } return result.toArray(new CacheInvocationParameter[0]); }
@Nullable private static CacheParameterDetail initializeValueParameterDetail( Method method, List<CacheParameterDetail> allParameters) { CacheParameterDetail result = null; for (CacheParameterDetail parameter : allParameters) { if (parameter.isValue()) { if (result == null) { result = parameter; } else { throw new IllegalArgumentException("More than one @CacheValue found on " + method + ""); } } } return result; }
/** * Return the {@link CacheInvocationParameter} for the parameter holding the value * to cache. * <p>The method arguments must match the signature of the related method invocation * @param values the parameters value for a particular invocation * @return the {@link CacheInvocationParameter} instance for the value parameter */ public CacheInvocationParameter getValueParameter(Object... values) { int parameterPosition = this.valueParameterDetail.getParameterPosition(); if (parameterPosition >= values.length) { throw new IllegalStateException("Values mismatch, value parameter at position " + parameterPosition + " cannot be matched against " + values.length + " value(s)"); } return this.valueParameterDetail.toCacheInvocationParameter(values[parameterPosition]); }
private static List<CacheParameterDetail> initializeKeyParameterDetails(List<CacheParameterDetail> allParameters) { List<CacheParameterDetail> all = new ArrayList<>(); List<CacheParameterDetail> annotated = new ArrayList<>(); for (CacheParameterDetail allParameter : allParameters) { if (!allParameter.isValue()) { all.add(allParameter); } if (allParameter.isKey()) { annotated.add(allParameter); } } return (annotated.isEmpty() ? all : annotated); }
@Override public CacheInvocationParameter[] getAllParameters(Object... values) { if (this.allParameterDetails.size() != values.length) { throw new IllegalStateException("Values mismatch, operation has " + this.allParameterDetails.size() + " parameter(s) but got " + values.length + " value(s)"); } List<CacheInvocationParameter> result = new ArrayList<>(); for (int i = 0; i < this.allParameterDetails.size(); i++) { result.add(this.allParameterDetails.get(i).toCacheInvocationParameter(values[i])); } return result.toArray(new CacheInvocationParameter[0]); }
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) { List<CacheParameterDetail> result = new ArrayList<>(); for (int i = 0; i < method.getParameterCount(); i++) { CacheParameterDetail detail = new CacheParameterDetail(method, i); result.add(detail); } return result; }