indigophox commented on code in PR #34817: URL: https://github.com/apache/arrow/pull/34817#discussion_r1420997101
########## java/flight/flight-core/src/main/java/org/apache/arrow/flight/SessionOptionValue.java: ########## @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.arrow.flight; + +import org.apache.arrow.flight.impl.Flight; + +/** + * A union-like container interface for supported session option value types. + */ +public abstract class SessionOptionValue { + static SessionOptionValue fromProto(Flight.SessionOptionValue proto); { + switch(proto.getOptionValueCase()) { + case STRING_VALUE: + return new SessionOptionValueString(proto.getStringValue()); + break; + case BOOL_VALUE: + return new SessionOptionValueBoolean(proto.getValue()); + break; + case INT32_VALUE: + return new SessionOptionValueInt(proto.getInt32Value()); + break; + case INT64_VALUE: + return new SessionOptionValueLong(proto.getInt64Value()); + break; + case FLOAT_VALUE: + return new SessionOptionValueFloat(proto.getFloatValue()); + break; + case DOUBLE_VALUE: + return new SessionOptionValueDouble(proto.getDoubleValue()); + break; + case STRING_LIST_VALUE: + // FIXME PHOXME is this what's in the ProtocolStringList? + return new SessionOptionValueStringList(proto.getValueStringList().stream().collect( + Collectors.toList(e -> google.protocol.StringValue.parseFrom(e).getValue()))); + break; + default: + // Unreachable + throw new IllegalArgumentException(""); + } + } + + /** + * Value access via a caller-provided visitor/functor. + */ + abstract void visit(SessionOptionValueVisitor); Review Comment: Done, thanks. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
