Examples of CapabilityProperty


Examples of org.sonatype.nexus.capabilities.client.spi.CapabilityProperty

  @Override
  public Object invoke(final Object proxy, final Method method, final Object[] args)
      throws Throwable
  {
    final CapabilityProperty capabilityProperty = method.getAnnotation(CapabilityProperty.class);
    if (capabilityProperty != null) {
      if (args == null || args.length == 0) {
        // we have a getter
        final String value = delegate.property(capabilityProperty.value());
        if (value == null || Void.TYPE.equals(method.getReturnType())) {
          return null;
        }
        if (method.getReturnType().isAssignableFrom(capabilityType)) {
          return proxy;
        }
        try {
          return Primitives.wrap(method.getReturnType())
              .getConstructor(String.class)
              .newInstance(value);
        }
        catch (final Exception e) {
          throw new ReflectiveCapabilityImplementationException(
              "Could not convert '" + value + "' to a " + method.getReturnType()
          );
        }
      }
      else if (args.length == 1) {
        delegate.withProperty(capabilityProperty.value(), args[0] == null ? null : args[0].toString());
        if (Void.TYPE.equals(method.getReturnType())) {
          return null;
        }
        if (method.getReturnType().isAssignableFrom(capabilityType)) {
          return proxy;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.