All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.cel.common.internal.SupplementalCodePointArray Maven / Gradle / Ivy

There is a newer version: 0.7.1
Show newest version
// Copyright 2022 Google LLC
//
// Licensed 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 dev.cel.common.internal;

import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndexes;

import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.Immutable;
import dev.cel.common.annotations.Internal;

/**
 * Array of code points that contain code points from Latin-1 character set, basic multilingual
 * plane or the supplemental multilingual plane.
 *
 * 

CEL Library Internals. Do Not Use. */ @Immutable @VisibleForTesting @Internal public final class SupplementalCodePointArray extends CelCodePointArray { @SuppressWarnings("Immutable") private final int[] codePoints; private final int offset; private final int size; SupplementalCodePointArray(int[] codePoints, int size) { this(codePoints, 0, size); } SupplementalCodePointArray(int[] codePoints, int offset, int size) { this.codePoints = checkNotNull(codePoints); this.offset = offset; this.size = size; } @Override public SupplementalCodePointArray slice(int i, int j) { checkPositionIndexes(i, j, size()); return new SupplementalCodePointArray(codePoints, offset + i, j - i); } @Override public int get(int index) { checkElementIndex(index, size()); return codePoints[offset + index]; } @Override public int size() { return size; } @Override public String toString() { return new String(codePoints, offset, size); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy