Package lombok.ast

Examples of lombok.ast.ResolutionException


    String packageName = null;
    if (value instanceof Select) {
      List<String> chain = unwrapSelectChain((Select) value);
      switch (chain.size()) {
      case 0:
        throw new ResolutionException(value, "empty");
      default:
        packageName = Joiner.on('.').join(chain.subList(0, chain.size() - 2));
      case 2:
        typeName = chain.get(chain.size() - 2);
      case 1:
        enumName = chain.get(chain.size() - 1);
      }
     
      boolean unexpectedType = false;
      if (packageName != null) {
        Package p = enumClass.getPackage();
        unexpectedType = p != null && !p.getName().equals(packageName);
      }
      unexpectedType |= (typeName != null && !enumClass.getSimpleName().equals(typeName));
     
      if (unexpectedType) throw new ResolutionException(value, "Expected " + enumClass.getName() + " and not " + packageName + "." + typeName);
    }
   
    for (E enumConstant : enumClass.getEnumConstants()) {
      String target = enumConstant.name();
      if (target.equals(enumName)) return enumConstant;
    }
   
    throw new ResolutionException(value, "Not a valid value for enum " + enumClass.getSimpleName() + ": " + enumName);
  }
View Full Code Here


        s = null;
        list.add(((Identifier)parent).astValue());
      } else if (parent == null) {
        break;
      } else {
        throw new ResolutionException(parent, "Identifies expected here, not a " + parent.getClass().getSimpleName());
      }
    }
   
    Collections.reverse(list);
    return list;
View Full Code Here

    if (val instanceof StringLiteral) {
      returnValues.add(((StringLiteral)val).astValue());
      return true;
    }
   
    throw new ResolutionException(val, "Expected string literal");
  }
View Full Code Here

      boolean v = ((BooleanLiteral)val).astValue();
      returnValues.add(v);
      return true;
    }
   
    throw new ResolutionException(val, "Expected boolean literal");
  }
View Full Code Here

      val = ((UnaryExpression)val).rawOperand();
      negative = true;
    }
   
    if (!(val instanceof IntegralLiteral) && !(val instanceof FloatingPointLiteral) && !(val instanceof CharLiteral)) {
      throw new ResolutionException(val, "Expected number or character literal");
    }
   
    boolean isIntegral = true;
    long iVal; {
      if (val instanceof IntegralLiteral) {
View Full Code Here

            } catch (ClassNotFoundException e) {
              classNotAvailable = new AnnotationClassNotAvailableException(val, className);
            } finally {
              classNames.add(className);
            }
          } else throw new ResolutionException(val, "Expected class literal");
        }
        if (expectedType.isAnnotation()) {
          if (val instanceof Annotation) {
            returnValues.add(this.resolver.toAnnotationInstance(expectedType.asSubclass(java.lang.annotation.Annotation.class), (Annotation)val));
            continue;
          } else {
            throw new ResolutionException(val, "Expected an annotation of type " + expectedType);
          }
        }
        throw new ResolutionException(val, "Not a valid annotation type: " + expectedType);
      }
    }
   
    if (classNotAvailable != null) {
      classNotAvailable.setClassNames(classNames);
      throw classNotAvailable;
    }
   
    if (array) {
      Object arr = Array.newInstance(expectedType, returnValues.size());
      for (int i = 0; i < returnValues.size(); i++) Array.set(arr, i, returnValues.get(i));
      return arr;
    }
   
    switch (returnValues.size()) {
    case 0:
      Object def = method.getDefaultValue();
      if (def != null) return def;
      throw new ResolutionException(node, "Missing annotation method: " + method.getName());
    case 1:
      return returnValues.get(0);
    default:
      throw new ResolutionException(node, "Multiple values for a single-value annotation method: " + method.getName());
    }
  }
View Full Code Here

TOP

Related Classes of lombok.ast.ResolutionException

Copyright © 2018 www.massapicom. 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.