public AstWriteOptionNodeBuilder() { this(new AstWriteOptionNode()); }
@Override protected final boolean equalTo(AstOptionNode that) { return that instanceof AstWriteOptionNode && equalTo((AstWriteOptionNode) that); }
public StreamNested<R> setOptionName(String optionName) { node.setOptionName(optionName); return this; }
@Override public Configuration visit(AstWriteOptionNode node, State state) { TypeInfo<?> optionType = node.getOptionType(); if (optionType == DefaultTypeSystem.OPTION_MASK) { AstValue<?> maskValue = node.getOptionValue(); state.writeMasker = maskValue.accept(new GenerateMaskOptionValueVisitor(), state); } else { ChannelHandler handler = behaviorSystem.newWriteOptionHandler(node); String optionName = node.getOptionName(); if (handler != null) { String handlerName = String.format("writeOption#%d (%s)", state.pipelineAsMap.size() + 1, optionName); state.pipelineAsMap.put(handlerName, handler); } else { throw new IllegalArgumentException("Unrecognized write option : " + optionName); } } return state.configuration; }
@Override public AstWriteOptionNode visitWriteOptionNode(WriteOptionNodeContext ctx) { String optionQName = ctx.optionName().getText(); TypeInfo<?> optionType = TYPE_SYSTEM.writeOption(optionQName); Class<?> expectedType = optionType.getType(); AstValueVisitor<?> visitor = new AstValueVisitor<>(factory, environment, expectedType); AstValue<?> optionValue = visitor.visit(ctx); childInfos().add(optionValue.getRegionInfo()); node = new AstWriteOptionNode(); node.setOptionType(optionType); node.setOptionName(optionQName); node.setOptionValue(optionValue); node.setRegionInfo(asSequentialRegion(childInfos, ctx)); return node; } }
@Override protected void describe(StringBuilder buf) { super.describe(buf); buf.append(format("write option %s %s\n", getOptionName(), getOptionValue())); } }
private static WriteOptionFileOffsetHandler newWriteFileOffsetHandler( AstWriteOptionNode node) { AstLiteralTextValue offsetValue = (AstLiteralTextValue) node.getOptionValue(); int offset = Integer.parseInt(offsetValue.getValue()); WriteOptionFileOffsetHandler handler = new WriteOptionFileOffsetHandler(offset); handler.setRegionInfo(node.getRegionInfo()); return handler; } }
public AstWriteOptionNodeBuilder setOptionValue(URI optionValue) { node.setOptionValue(new AstLiteralURIValue(optionValue)); return this; }
@Override public AstWriteOptionNode visitWriteOptionNode(WriteOptionNodeContext ctx) { AstWriteOptionNodeVisitor visitor = new AstWriteOptionNodeVisitor(factory, environment); AstWriteOptionNode optionNode = visitor.visitWriteOptionNode(ctx); if (optionNode != null) { childInfos().add(optionNode.getRegionInfo()); } return optionNode; } }
public AstWriteOptionNodeBuilder setOptionType(TypeInfo<?> optionType) { node.setOptionType(optionType); return this; }
public ChannelHandler newWriteOptionHandler( AstWriteOptionNode node) { TypeInfo<?> optionType = node.getOptionType(); WriteOptionFactory factory = writeOptions.getOrDefault(optionType, n -> null); return factory.newHandler(node); }
public StreamNested<R> setOptionValue(long optionValue) { node.setOptionValue(new AstLiteralLongValue(optionValue)); return this; }
public StreamNested<R> setOptionType(TypeInfo<?> optionType) { node.setOptionType(optionType); return this; }
public AstWriteOptionNodeBuilder setOptionValue(String optionValue) { node.setOptionValue(new AstLiteralTextValue(optionValue)); return this; }
public AstWriteOptionNodeBuilder setOptionName(String optionName) { node.setOptionName(optionName); return this; }
public StreamNested(R builder) { super(new AstWriteOptionNode(), builder); }
public AstWriteOptionNodeBuilder setOptionValue(ValueExpression expression, ExpressionContext environment) { node.setOptionValue(new AstExpressionValue<>(expression, environment)); return this; }
public AstWriteOptionNodeBuilder setOptionValue(int optionValue) { node.setOptionValue(new AstLiteralIntegerValue(optionValue)); return this; }
public StreamNested<R> setOptionValue(int optionValue) { node.setOptionValue(new AstLiteralIntegerValue(optionValue)); return this; }
public StreamNested<R> setOptionValue(ValueExpression expression, ExpressionContext environment) { node.setOptionValue(new AstExpressionValue<>(expression, environment)); return this; }