public Directive directive(String name) { for (Directive d : directives) if (d.getName().equals(name)) return d; return null; } }
public boolean hasDirective(String name) { for (Directive d : directives) if (d.getName().equals(name)) return true; return false; }
private boolean checkBooleanDirective(Directive dir) throws EGraphQLException { if (dir.getArguments().size() != 1) throw new EGraphQLException("Unable to process @"+dir.getName()+": expected a single argument \"if\""); if (!dir.getArguments().get(0).getName().equals("if")) throw new EGraphQLException("Unable to process @"+dir.getName()+": expected a single argument \"if\""); List<Value> vl = resolveValues(dir.getArguments().get(0), 1); return vl.get(0).toString().equals("true"); }
private boolean checkDirectives(List<Directive> directives) throws EGraphQLException { Directive skip = null; Directive include = null; for (Directive dir : directives) { if (dir.getName().equals("skip")) { if ((skip == null)) skip = dir; else throw new EGraphQLException("Duplicate @skip directives"); } else if (dir.getName().equals("include")) { if ((include == null)) include = dir; else throw new EGraphQLException("Duplicate @include directives"); } else if (!Utilities.existsInList(dir.getName(), "flatten", "first", "singleton", "slice")) throw new EGraphQLException("Directive \""+dir.getName()+"\" instanceof not recognised"); } if ((skip != null && include != null)) throw new EGraphQLException("Cannot mix @skip and @include directives"); if (skip != null) return !checkBooleanDirective(skip); else if (include != null) return checkBooleanDirective(include); else return true; }
public Directive directive(String name) { for (Directive d : directives) if (d.getName().equals(name)) return d; return null; } }
public boolean hasDirective(String name) { for (Directive d : directives) if (d.getName().equals(name)) return true; return false; }
private boolean checkBooleanDirective(Directive dir) throws EGraphQLException { if (dir.getArguments().size() != 1) throw new EGraphQLException("Unable to process @"+dir.getName()+": expected a single argument \"if\""); if (!dir.getArguments().get(0).getName().equals("if")) throw new EGraphQLException("Unable to process @"+dir.getName()+": expected a single argument \"if\""); List<Value> vl = resolveValues(dir.getArguments().get(0), 1); return vl.get(0).toString().equals("true"); }
private boolean checkDirectives(List<Directive> directives) throws EGraphQLException { Directive skip = null; Directive include = null; for (Directive dir : directives) { if (dir.getName().equals("skip")) { if ((skip == null)) skip = dir; else throw new EGraphQLException("Duplicate @skip directives"); } else if (dir.getName().equals("include")) { if ((include == null)) include = dir; else throw new EGraphQLException("Duplicate @include directives"); } else if (!Utilities.existsInList(dir.getName(), "flatten", "first", "singleton", "slice")) throw new EGraphQLException("Directive \""+dir.getName()+"\" instanceof not recognised"); } if ((skip != null && include != null)) throw new EGraphQLException("Cannot mix @skip and @include directives"); if (skip != null) return !checkBooleanDirective(skip); else if (include != null) return checkBooleanDirective(include); else return true; }