keith-turner commented on code in PR #4748: URL: https://github.com/apache/accumulo/pull/4748#discussion_r1707977384
########## core/src/main/java/org/apache/accumulo/core/data/EmptyByteSequence.java: ########## @@ -0,0 +1,87 @@ +/* + * 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 + * + * https://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.accumulo.core.data; + +import java.util.Objects; + +/** + * An immutable implementation of {@link ByteSequence} specialized for the empty case. + * + * <p> + * This class is package private because direct construction is not expected, instead use of + * {@link ByteSequence#of()} is how instances of this should be created. + * </p> + */ +final class EmptyByteSequence extends ByteSequence { + + private static final long serialVersionUID = 1L; + + static final ByteSequence INSTANCE = new EmptyByteSequence(); + + private static final byte[] EMPTY = new byte[0]; + + // constructor is private because this class is a singleton + private EmptyByteSequence() {} + + @Override + public byte byteAt(int i) { + throw new IndexOutOfBoundsException(); Review Comment: Was trying to make all of the different impls of this method throw the same exception. Made some improvements related to the exception in a7bf73f -- 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]
