@Test public void textLookupByExpressionClass() { assertEquals(definition1, definitions.getExpressionEditorDefinition(Optional.of(new LiteralExpression())).get()); assertEquals(definition2, definitions.getExpressionEditorDefinition(Optional.of(new Context())).get()); }
public Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final Optional<Expression> expression) { if (!expression.isPresent()) { return this.stream() .filter(ed -> !ed.getModelClass().isPresent()) .findFirst(); } else { return this.stream() .filter(ed -> ed.getModelClass().isPresent()) .filter(ed -> ed.getModelClass().get().getClass().equals(expression.get().getClass())) .findFirst(); } }
ExpressionEditorDefinitions extends ArrayList<ExpressionEditorDefinition<Expression>> { public Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final Optional<Expression> expression) { if (!expression.isPresent()) { return this.stream() .filter(ed -> !ed.getModelClass().isPresent()) .findFirst(); } else { return this.stream() .filter(ed -> ed.getModelClass().isPresent()) .filter(ed -> ed.getModelClass().get().getClass().equals(expression.get().getClass())) .findFirst(); } } }
ExpressionEditorDefinitions extends ArrayList<ExpressionEditorDefinition<Expression>> { public Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final Optional<Expression> expression) { if (!expression.isPresent()) { return this.stream() .filter(ed -> !ed.getModelClass().isPresent()) .findFirst(); } else { return this.stream() .filter(ed -> ed.getModelClass().isPresent()) .filter(ed -> ed.getModelClass().get().getClass().equals(expression.get().getClass())) .findFirst(); } }  }
ExpressionEditorDefinitions extends ArrayList<ExpressionEditorDefinition<Expression>> { public Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final Optional<Expression> expression) { if (!expression.isPresent()) { return this.stream() .filter(ed -> !ed.getModelClass().isPresent()) .findFirst(); } else { return this.stream() .filter(ed -> ed.getModelClass().isPresent()) .filter(ed -> ed.getModelClass().get().getClass().equals(expression.get().getClass())) .findFirst(); } }  Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final Optional<Expression> expression); Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final ExpressionType type); }
ExpressionEditorDefinitions extends ArrayList<ExpressionEditorDefinition<Expression>> { public Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final Optional<Expression> expression) { if (!expression.isPresent()) { return this.stream() .filter(ed -> !ed.getModelClass().isPresent()) .findFirst(); } else { return this.stream() .filter(ed -> ed.getModelClass().isPresent()) .filter(ed -> ed.getModelClass().get().getClass().equals(expression.get().getClass())) .findFirst(); } }  Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final Optional<Expression> expression); Optional<ExpressionEditorDefinition<Expression>> getExpressionEditorDefinition(final ExpressionType type);  }