text:
/*
 * Copyright 2012-2017 the original author or authors.
 *
 * 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
 *
 *      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.springframework.boot.autoconfigure.mongo;

import java.net.UnknownHostException;
import java.util.List;

import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.mongodb.async.client.MongoClientSettings;
import com.mongodb.connection.ClusterSettings;
import com.mongodb.reactivestreams.client.MongoClient;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import org.springframework.core.env.Environment;
import org.springframework.mock.env.MockEnvironment;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Tests for {@link ReactiveMongoClientFactory}.
 *
 * @author Mark Paluch
 * @author Stephane Nicoll
 */
public class ReactiveMongoClientFactoryTests {

	@Rule
	public ExpectedException thrown = ExpectedException.none();

	private MockEnvironment environment = new MockEnvironment();

	@Test
	public void portCanBeCustomized() throws UnknownHostException {
		MongoProperties properties = new MongoProperties();
		properties.setPort(12345);
		MongoClient client = createMongoClient(properties);
		List<ServerAddress> allAddresses = extractServerAddresses(client);
		assertThat(allAddresses).hasSize(1);
		assertServerAddress(allAddresses.get(0), "localhost", 12345);
	}

	@Test
	public void hostCanBeCustomized() throws UnknownHostException {
		MongoProperties properties = new MongoProperties();
		properties.setHost("mongo.example.com");
		MongoClient client = createMongoClient(properties);
		List<ServerAddress> allAddresses = extractServerAddresses(client);
		assertThat(allAddresses).hasSize(1);
		assertServerAddress(allAddresses.get(0), "mongo.example.com", 27017);
	}

	@Test
	public void credentialsCanBeCustomized() throws UnknownHostException {
		MongoProperties properties = new MongoProperties();
		properties.setUsername("user");
		properties.setPassword("secret".toCharArray());
		MongoClient client = createMongoClient(properties);
		assertMongoCredential(extractMongoCredentials(client).get(0), "user", "secret",
				"test");
	}

	@Test
	public void databaseCanBeCustomized() throws UnknownHostException {
		MongoProperties properties = new MongoProperties();
		properties.setDatabase("foo");
		properties.setUsername("user");
		properties.setPassword("secret".toCharArray());
		MongoClient client = createMongoClient(properties);
		assertMongoCredential(extractMongoCredentials(client).get(0), "user", "secret",
				"foo");
	}

	@Test
	public void authenticationDatabaseCanBeCustomized() throws UnknownHostException {
		MongoProperties properties = new MongoProperties();
		properties.setAuthenticationDatabase("foo");
		properties.setUsername("user");
		properties.setPassword("secret".toCharArray());
		MongoClient client = createMongoClient(properties);
		assertMongoCredential(extractMongoCredentials(client).get(0), "user", "secret",
				"foo");
	}

	@Test
	public void uriCanBeCustomized() throws UnknownHostException {
		MongoProperties properties = new MongoProperties();
		properties.setUri("mongodb://user:secret@mongo1.example.com:12345,"
				+ "mongo2.example.com:23456/test");
		MongoClient client = createMongoClient(properties);
		List<ServerAddress> allAddresses = extractServerAddresses(client);
		assertThat(allAddresses).hasSize(2);
		assertServerAddress(allAddresses.get(0), "mongo1.example.com", 12345);
		assertServerAddress(allAddresses.get(1), "mongo2.example.com", 23456);
		List<MongoCredential> credentialsList = extractMongoCredentials(client);
		assertThat(credentialsList).hasSize(1);
		assertMongoCredential(credentialsList.get(0), "user", "secret", "test");
	}

	@Test
	public void uriCannotBeSetWithCredentials() throws UnknownHostException {
		MongoProperties properties = new MongoProperties();
		properties.setUri("mongodb://127.0.0.1:1234/mydb");
		properties.setUsername("user");
		properties.setPassword("secret".toCharArray());
		this.thrown.expect(IllegalStateException.class);
		this.thrown.expectMessage("Invalid mongo configuration, "
				+ "either uri or host/port/credentials must be specified");
		createMongoClient(properties);
	}

	@Test
	public void uriCannotBeSetWithHostPort() throws UnknownHostException {
		MongoProperties properties = new MongoProperties();
		properties.setUri("mongodb://127.0.0.1:1234/mydb");
		properties.setHost("localhost");
		properties.setPort(4567);
		this.thrown.expect(IllegalStateException.class);
		this.thrown.expectMessage("Invalid mongo configuration, "
				+ "either uri or host/port/credentials must be specified");
		createMongoClient(properties);
	}

	@Test
	public void uriIsIgnoredInEmbeddedMode() throws UnknownHostException {
		MongoProperties properties = new MongoProperties();
		properties.setUri("mongodb://mongo.example.com:1234/mydb");
		this.environment.setProperty("local.mongo.port", "4000");
		MongoClient client = createMongoClient(properties, this.environment);
		List<ServerAddress> allAddresses = extractServerAddresses(client);
		assertThat(allAddresses).hasSize(1);
		assertServerAddress(allAddresses.get(0), "localhost", 4000);
	}

	private MongoClient createMongoClient(MongoProperties properties) {
		return createMongoClient(properties, this.environment);
	}

	private MongoClient createMongoClient(MongoProperties properties,
			Environment environment) {
		return new ReactiveMongoClientFactory(properties, environment)
				.createMongoClient(null);
	}

	private List<ServerAddress> extractServerAddresses(MongoClient client) {
		MongoClientSettings settings = client.getSettings();
		ClusterSettings clusterSettings = settings.getClusterSettings();
		List<ServerAddress> allAddresses = clusterSettings.getHosts();
		return allAddresses;
	}

	private List<MongoCredential> extractMongoCredentials(MongoClient client) {
		MongoClientSettings settings = client.getSettings();
		return settings.getCredentialList();
	}

	private void assertServerAddress(ServerAddress serverAddress, String expectedHost,
			int expectedPort) {
		assertThat(serverAddress.getHost()).isEqualTo(expectedHost);
		assertThat(serverAddress.getPort()).isEqualTo(expectedPort);
	}

	private void assertMongoCredential(MongoCredential credentials,
			String expectedUsername, String expectedPassword, String expectedSource) {
		assertThat(credentials.getUserName()).isEqualTo(expectedUsername);
		assertThat(credentials.getPassword()).isEqualTo(expectedPassword.toCharArray());
		assertThat(credentials.getSource()).isEqualTo(expectedSource);
	}

}


text:
/*
 * Copyright 2019 The TensorFlow Authors. All Rights Reserved.
 *
 * 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
 *
 *       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.tensorflow.lite.examples.textclassification.client;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import androidx.test.core.app.ApplicationProvider;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;

/** Tests of {@link TextClassificationClient} */
@RunWith(RobolectricTestRunner.class)
public final class UnitTest {
  private TextClassificationClient client;

  @Before
  public void setUp() {
    client = new TextClassificationClient(ApplicationProvider.getApplicationContext());
    client.load();
  }

  @Test
  public void loadModelTest() {
    assertNotNull(client.getTflite());
  }

  @Test
  public void loadDictinaryTest() {
    assertEquals(0, (int) client.getDic().get("<PAD>"));
    assertEquals(1, (int) client.getDic().get("<START>"));
    assertEquals(2, (int) client.getDic().get("<UNKNOWN>"));
    assertEquals(3, (int) client.getDic().get("the"));
  }

  @Test
  public void loadLabelsTest() {
    List<String> labels = client.getLabels();
    assertEquals("Negative", labels.get(0));
    assertEquals("Positive", labels.get(1));
  }

  @Test
  public void inputPreprocessingTest() {
    int[][] clientOutput = client.tokenizeInputText("hello,world!");
    int[][] expectOutput = new int[1][256];
    Arrays.fill(expectOutput[0], 0, 255, 0);
    expectOutput[0][0] = 1; // Index for <START>
    expectOutput[0][1] = 4845; // Index for "hello".
    expectOutput[0][2] = 181; // Index for "world".
    assertArrayEquals(expectOutput, clientOutput);
  }

  @Test
  public void predictTest() {
    Result positiveText =
        client
            .classify("This is an interesting film. My family and I all liked it very much.")
            .get(0);
    assertEquals("Positive", positiveText.getTitle());
    assertTrue(positiveText.getConfidence() > 0.55);
    Result negativeText =
        client.classify("This film cannot be worse. It is way too boring.").get(0);
    assertEquals("Negative", negativeText.getTitle());
    assertTrue(negativeText.getConfidence() > 0.6);
  }
}

domain: java


text:
/*
 * Copyright (c) 2009-2021 jMonkeyEngine
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 * * Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 *
 * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
 *   may be used to endorse or promote products derived from this software
 *   without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.jme3.texture;

import com.jme3.export.InputCapsule;
import com.jme3.export.JmeExporter;
import com.jme3.export.JmeImporter;
import com.jme3.export.OutputCapsule;
import com.jme3.export.Savable;
import com.jme3.math.FastMath;
import com.jme3.renderer.Caps;
import com.jme3.renderer.Renderer;
import com.jme3.texture.image.ColorSpace;
import com.jme3.texture.image.LastTextureState;
import com.jme3.util.BufferUtils;
import com.jme3.util.NativeObject;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Image defines a data format for a graphical image. The image
 * is defined by a format, a height and width, and the image data. The width and
 * height must be greater than 0. The data is contained in a byte buffer, and
 * should be packed before creation of the image object.
 *
 * @author Mark Powell
 * @author Joshua Slack
 * @version $Id: Image.java 4131 2009-03-19 20:15:28Z blaine.dev $
 */
public class Image extends NativeObject implements Savable /*, Cloneable*/ {

    public enum Format {
        /**
         * 8-bit alpha
         */
        Alpha8(8),

        @Deprecated
        Reserved1(0),

        /**
         * 8-bit grayscale/luminance.
         */
        Luminance8(8),

        @Deprecated
        Reserved2(0),

        /**
         * half-precision floating-point grayscale/luminance.
         *
         * Requires {@link Caps#FloatTexture}.
         */
        Luminance16F(16,true),

        /**
         * single-precision floating-point grayscale/luminance.
         *
         * Requires {@link Caps#FloatTexture}.
         */
        Luminance32F(32,true),

        /**
         * 8-bit luminance/grayscale and 8-bit alpha.
         */
        Luminance8Alpha8(16),

        @Deprecated
        Reserved3(0),

        /**
         * half-precision floating-point grayscale/luminance and alpha.
         *
         * Requires {@link Caps#FloatTexture}.
         */
        Luminance16FAlpha16F(32,true),

        @Deprecated
        Reserved4(0),

        @Deprecated
        Reserved5(0),

        /**
         * 8-bit blue, green, and red.
         */
        BGR8(24), // BGR and ABGR formats are often used on windows systems

        /**
         * 8-bit red, green, and blue.
         */
        RGB8(24),

        @Deprecated
        Reserved6(0),

        @Deprecated
        Reserved7(0),

        /**
         * 5-bit red, 6-bit green, and 5-bit blue.
         */
        RGB565(16),

        @Deprecated
        Reserved8(0),

        /**
         * 5-bit red, green, and blue with 1-bit alpha.
         */
        RGB5A1(16),

        /**
         * 8-bit red, green, blue, and alpha.
         */
        RGBA8(32),

        /**
         * 8-bit alpha, blue, green, and red.
         */
        ABGR8(32),

        /**
         * 8-bit alpha, red, blue and green
         */
        ARGB8(32),

        /**
         * 8-bit blue, green, red and alpha.
         */
        BGRA8(32),

        @Deprecated
        Reserved9(0),

        /**
         * S3TC compression DXT1.
         */
        DXT1(4,false,true, false),

        /**
         * S3TC compression DXT1 with 1-bit alpha.
         */
        DXT1A(4,false,true, false),

        /**
         * S3TC compression DXT3 with 4-bit alpha.
         */
        DXT3(8,false,true, false),

        /**
         * S3TC compression DXT5 with interpolated 8-bit alpha.
         *
         */
        DXT5(8,false,true, false),

        RGTC2(8,false,true, false),

        SIGNED_RGTC2(8,false,true, false),

        RGTC1(4,false,true, false),

        SIGNED_RGTC1(4,false,true, false),

        /**
         * Luminance-Alpha Texture Compression.
         *
         * @deprecated Not supported by OpenGL 3.0.
         */
        @Deprecated
        Reserved10(0),

        /**
         * Arbitrary depth format. The precision is chosen by the video
         * hardware.
         */
        Depth(0,true,false,false),

        /**
         * 16-bit depth.
         */
        Depth16(16,true,false,false),

        /**
         * 24-bit depth.
         */
        Depth24(24,true,false,false),

        /**
         * 32-bit depth.
         */
        Depth32(32,true,false,false),

        /**
         * single-precision floating point depth.
         *
         * Requires {@link Caps#FloatDepthBuffer}.
         */
        Depth32F(32,true,false,true),

        /**
         * Texture data is stored as {@link Format#RGB16F} in system memory,
         * but will be converted to {@link Format#RGB111110F} when sent
         * to the video hardware.
         *
         * Requires {@link Caps#FloatTexture} and {@link Caps#PackedFloatTexture}.
         */
        RGB16F_to_RGB111110F(48,true),

        /**
         * unsigned floating-point red, green and blue that uses 32 bits.
         *
         * Requires {@link Caps#PackedFloatTexture}.
         */
        RGB111110F(32,true),

        /**
         * Texture data is stored as {@link Format#RGB16F} in system memory,
         * but will be converted to {@link Format#RGB9E5} when sent
         * to the video hardware.
         *
         * Requires {@link Caps#FloatTexture} and {@link Caps#SharedExponentTexture}.
         */
        RGB16F_to_RGB9E5(48,true),

        /**
         * 9-bit red, green and blue with 5-bit exponent.
         *
         * Requires {@link Caps#SharedExponentTexture}.
         */
        RGB9E5(32,true),

        /**
         * half-precision floating point red, green, and blue.
         *
         * Requires {@link Caps#FloatTexture}.
         * May be supported for renderbuffers, but the OpenGL specification does not require it.
         */
        RGB16F(48,true),

        /**
         * half-precision floating point red, green, blue, and alpha.
         *
         * Requires {@link Caps#FloatTexture}.
         */
        RGBA16F(64,true),

        /**
         * single-precision floating point red, green, and blue.
         *
         * Requires {@link Caps#FloatTexture}.
         * May be supported for renderbuffers, but the OpenGL specification does not require it.
         */
        RGB32F(96,true),

        /**
         * single-precision floating point red, green, blue and alpha.
         *
         * Requires {@link Caps#FloatTexture}.
         */
        RGBA32F(128,true),

        @Deprecated
        Reserved11(0),

        /**
         * 24-bit depth with 8-bit stencil.
         * Check the cap {@link Caps#PackedDepthStencilBuffer}.
         */
        Depth24Stencil8(32, true, false, false),

        @Deprecated
        Reserved12(0),

        /**
         * Ericsson Texture Compression. Typically used on Android.
         *
         * Requires {@link Caps#TextureCompressionETC1}.
         */
        ETC1(4, false, true, false),

        /**
         * 8 bit signed int red.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        R8I(8),
        /**
         * 8 bit unsigned int red.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        R8UI(8),
        /**
         * 16 bit signed int red.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        R16I(16),
        /**
         * 16 bit unsigned int red.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        R16UI(16),
        /**
         * 32 bit signed int red.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        R32I(32),
        /**
         * 32 bit unsigned int red.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        R32UI(32),

        /**
         * 8 bit signed int red and green.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RG8I(16),
        /**
         * 8 bit unsigned int red and green.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RG8UI(16),
        /**
         * 16 bit signed int red and green.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RG16I(32),
        /**
         * 16 bit unsigned int red and green.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RG16UI(32),
        /**
         * 32 bit signed int red and green.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RG32I(64),
        /**
         * 32 bit unsigned int red and green.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RG32UI(64),

        /**
         * 8 bit signed int red, green and blue.
         *
         * Requires {@link Caps#IntegerTexture} to be supported for textures.
         * May be supported for renderbuffers, but the OpenGL specification does not require it.
         */
        RGB8I(24),
        /**
         * 8 bit unsigned int red, green and blue.
         *
         * Requires {@link Caps#IntegerTexture} to be supported for textures.
         * May be supported for renderbuffers, but the OpenGL specification does not require it.
         */
        RGB8UI(24),
        /**
         * 16 bit signed int red, green and blue.
         *
         * Requires {@link Caps#IntegerTexture} to be supported for textures.
         * May be supported for renderbuffers, but the OpenGL specification does not require it.
         */
        RGB16I(48),
        /**
         * 16 bit unsigned int red, green and blue.
         *
         * Requires {@link Caps#IntegerTexture} to be supported for textures.
         * May be supported for renderbuffers, but the OpenGL specification does not require it.
         */
        RGB16UI(48),
        /**
         * 32 bit signed int red, green and blue.
         *
         * Requires {@link Caps#IntegerTexture} to be supported for textures.
         * May be supported for renderbuffers, but the OpenGL specification does not require it.
         */
        RGB32I(96),
        /**
         * 32 bit unsigned int red, green and blue.
         *
         * Requires {@link Caps#IntegerTexture} to be supported for textures.
         * May be supported for renderbuffers, but the OpenGL specification does not require it.
         */
        RGB32UI(96),

        /**
         * 8 bit signed int red, green, blue and alpha.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RGBA8I(32),
        /**
         * 8 bit unsigned int red, green, blue and alpha.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RGBA8UI(32),
        /**
         * 16 bit signed int red, green, blue and alpha.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RGBA16I(64),
        /**
         * 16 bit unsigned int red, green, blue and alpha.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RGBA16UI(64),
        /**
         * 32 bit signed int red, green, blue and alpha.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RGBA32I(128),
        /**
         * 32 bit unsigned int red, green, blue and alpha.
         *
         * Requires {@link Caps#IntegerTexture}.
         */
        RGBA32UI(128),

        /**
         * half-precision floating point red.
         *
         * Requires {@link Caps#FloatTexture}.
         */
        R16F(16,true),

        /**
         * single-precision floating point red.
         *
         * Requires {@link Caps#FloatTexture}.
         */
        R32F(32,true),

        /**
         * half-precision floating point red and green.
         *
         * Requires {@link Caps#FloatTexture}.
         */
        RG16F(32,true),

        /**
         * single-precision floating point red and green.
         *
         * Requires {@link Caps#FloatTexture}.
         */
        RG32F(64,true),

        /**
         * 10-bit red, green, and blue with 2-bit alpha.
         */
        RGB10A2(32),
        ;

        private int bpp;
        private boolean isDepth;
        private boolean isCompressed;
        private boolean isFloatingPoint;

        private Format(int bpp){
            this.bpp = bpp;
        }

        private Format(int bpp, boolean isFP){
            this(bpp);
            this.isFloatingPoint = isFP;
        }

        private Format(int bpp, boolean isDepth, boolean isCompressed, boolean isFP){
            this(bpp, isFP);
            this.isDepth = isDepth;
            this.isCompressed = isCompressed;
        }

        /**
         * @return bits per pixel.
         */
        public int getBitsPerPixel(){
            return bpp;
        }

        /**
         * @return True if this format is a depth format, false otherwise.
         */
        public boolean isDepthFormat(){
            return isDepth;
        }

        /**
         * @return True if this format is a depth + stencil (packed) format, false otherwise.
         */
        boolean isDepthStencilFormat() {
            return this == Depth24Stencil8;
        }

        /**
         * @return True if this is a compressed image format, false if
         * uncompressed.
         */
        public boolean isCompressed() {
            return isCompressed;
        }

        /**
         * @return True if this image format is in floating point,
         * false if it is an integer format.
         */
        public boolean isFloatingPont(){
            return isFloatingPoint;
        }

    }

    // image attributes
    protected Format format;
    protected int width, height, depth;
    protected int[] mipMapSizes;
    protected ArrayList<ByteBuffer> data;
    protected int multiSamples = 1;
    protected ColorSpace colorSpace = null;
//    protected int mipOffset = 0;

    // attributes relating to GL object
    protected boolean mipsWereGenerated = false;
    protected boolean needGeneratedMips = false;
    protected LastTextureState lastTextureState = new LastTextureState();

    /**
     * Internal use only.
     * The renderer stores the texture state set from the last texture
     * so it doesn't have to change it unless necessary.
     *
     * @return The image parameter state.
     */
    public LastTextureState getLastTextureState() {
        return lastTextureState;
    }

    /**
     * Internal use only.
     * The renderer marks which images have generated mipmaps in VRAM
     * and which do not, so it can generate them as needed.
     *
     * @param generated If mipmaps were generated or not.
     */
    public void setMipmapsGenerated(boolean generated) {
        this.mipsWereGenerated = generated;
    }

    /**
     * Internal use only.
     * Check if the renderer has generated mipmaps for this image in VRAM
     * or not.
     *
     * @return If mipmaps were generated already.
     */
    public boolean isMipmapsGenerated() {
        return mipsWereGenerated;
    }

    /**
     * (Package private) Called by {@link Texture} when
     * {@link #isMipmapsGenerated() } is false in order to generate
     * mipmaps for this image.
     */
    void setNeedGeneratedMipmaps() {
        needGeneratedMips = true;
    }

    /**
     * @return True if the image needs to have mipmaps generated
     * for it (as requested by the texture). This stays true even
     * after mipmaps have been generated.
     */
    public boolean isGeneratedMipmapsRequired() {
        return needGeneratedMips;
    }

    /**
     * Sets the update needed flag, while also checking if mipmaps
     * need to be regenerated.
     */
    @Override
    public void setUpdateNeeded() {
        super.setUpdateNeeded();
        if (isGeneratedMipmapsRequired() && !hasMipmaps()) {
            // Mipmaps are no longer valid, since the image was changed.
            setMipmapsGenerated(false);
        }
    }

    /**
     * Determine if the image is NPOT.
     *
     * @return if the image is a non-power-of-2 image, e.g. having dimensions
     * that are not powers of 2.
     */
    public boolean isNPOT() {
        return width != 0 && height != 0
                && (!FastMath.isPowerOfTwo(width) || !FastMath.isPowerOfTwo(height));
    }

    @Override
    public void resetObject() {
        this.id = -1;
        this.mipsWereGenerated = false;
        this.lastTextureState.reset();
        setUpdateNeeded();
    }

    @Override
    protected void deleteNativeBuffers() {
        for (ByteBuffer buf : data) {
            BufferUtils.destroyDirectBuffer(buf);
        }
    }

    @Override
    public void deleteObject(Object rendererObject) {
        ((Renderer)rendererObject).deleteImage(this);
    }

    @Override
    public NativeObject createDestructableClone() {
        return new Image(id);
    }

    @Override
    public long getUniqueId() {
        return ((long)OBJTYPE_TEXTURE << 32) | ((long)id);
    }

    /**
     * @return A shallow clone of this image. The data is not cloned.
     */
    @Override
    public Image clone(){
        Image clone = (Image) super.clone();
        clone.mipMapSizes = mipMapSizes != null ? mipMapSizes.clone() : null;
        clone.data = data != null ? new ArrayList<ByteBuffer>(data) : null;
        clone.lastTextureState = new LastTextureState();


text:
package net.craftmountain.myannouncements.commands;

import net.craftmountain.myannouncements.utilities.Announcer;
import net.craftmountain.myannouncements.utilities.Utilities;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

public class CommandToggle implements MyAnnouncementsCommand {

    private String command;

    public CommandToggle(String command) {
        this.command = command;
    }

    @Override
    public void onCommand(CommandSender sender, String[] args) {
        if (!(Utilities.hasPermission(sender, "ma.admin"))) {
            sender.sendMessage(ChatColor.RED + "You don't have permission to use this command!");
        } else {
            boolean paused;
            Announcer.getInstance().setPaused(paused = !Announcer.getInstance().isPaused());
            sender.sendMessage(ChatColor.GREEN + "You have successfully " + (paused ? "paused" : "unpaused") + " the announcements!");
        }
    }

    @Override
    public String getCommand() {
        return command;
    }

}


text:
// Template Source: IBaseEntityRequestBuilder.java.tt
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All Rights Reserved.  Licensed under the MIT License.  See License in the project root for license information.
// ------------------------------------------------------------------------------

package com.microsoft.graph.requests.extensions;

import com.microsoft.graph.http.IRequestBuilder;
import com.microsoft.graph.core.ClientException;
import com.microsoft.graph.concurrency.ICallback;
import com.microsoft.graph.models.extensions.User;
import java.util.Arrays;
import java.util.EnumSet;

// **NOTE** This file was generated by a tool and any changes will be overwritten.

/**
 * The interface for the User Request Builder.
 */
public interface IUserRequestBuilder extends IRequestBuilder {
    /**
     * Creates the request
     *
     * @param requestOptions the options for this request
     * @return the IUserRequest instance
     */
    IUserRequest buildRequest(final com.microsoft.graph.options.Option... requestOptions);

    /**
     * Creates the request with specific options instead of the existing options
     *
     * @param requestOptions the options for this request
     * @return the IUserRequest instance
     */
    IUserRequest buildRequest(final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions);

}


text:
package com.sustly;

import com.alibaba.cloud.sentinel.annotation.SentinelRestTemplate;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: liyue
 * @Date: 19-9-4 下午5:48
 */
@SpringBootApplication
@EnableFeignClients(basePackages = {"com.sustly"})
@EnableDiscoveryClient
public class BlogConsumerFeign {
    public static void main(String[] args) {
        SpringApplication.run(BlogConsumerFeign.class, args);
    }

    @Bean
    @SentinelRestTemplate
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }
}


text:
package io.dropwizard.configuration;

import io.dropwizard.util.ByteStreams;
import io.dropwizard.util.Resources;
import org.junit.jupiter.api.Test;

import java.io.InputStream;
import java.nio.charset.StandardCharsets;

import static org.assertj.core.api.Assertions.assertThat;

public class UrlConfigurationSourceProviderTest {
    private final ConfigurationSourceProvider provider = new UrlConfigurationSourceProvider();

    @Test
    public void readsFileContents() throws Exception {
        try (InputStream input = provider.open(Resources.getResource("example.txt").toString())) {
            assertThat(new String(ByteStreams.toByteArray(input), StandardCharsets.UTF_8).trim())
                .isEqualTo("whee");
        }
    }
}


text:
package org.opencb.biodata.tools.variant.converters.proto;

import htsjdk.variant.variantcontext.Genotype;
import htsjdk.variant.variantcontext.VariantContext;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.opencb.biodata.models.variant.Variant;
import org.opencb.biodata.models.variant.VariantBuilder;
import org.opencb.biodata.models.variant.protobuf.VariantAnnotationProto;
import org.opencb.biodata.models.variant.protobuf.VariantProto;
import org.opencb.biodata.tools.variant.converters.VariantContextConverter;
import org.opencb.commons.datastore.core.ObjectMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.function.BiFunction;
import java.util.stream.Collectors;

import static org.opencb.biodata.formats.variant.vcf4.VcfUtils.*;

/**
 * Created by jtarraga on 07/02/17.
 */
public class VariantProtoToVariantContextConverter extends VariantContextConverter<VariantProto.Variant> {

    private final Logger logger = LoggerFactory.getLogger(VariantProtoToVariantContextConverter.class);

    @Deprecated
    public VariantProtoToVariantContextConverter(int studyId) {
        super(null, null, null, null);
    }

    public VariantProtoToVariantContextConverter(String study, List<String> sampleNames, List<String> annotations) {
        this(study, sampleNames, null, annotations);
    }

    public VariantProtoToVariantContextConverter(String study, List<String> sampleNames, List<String> sampleFormats,
                                                 List<String> annotations) {
        super(study, sampleNames, sampleFormats, annotations);
    }

    @Override
    public VariantContext convert(VariantProto.Variant variant) {
        init(variant);

        VariantProto.StudyEntry studyEntry = getStudy(variant);

        List<Map<String, String>> fileAttributes = studyEntry.getFilesList().stream()
                .map(VariantProto.FileEntry::getDataMap)
                .collect(Collectors.toList());

        // CHROM START END REFERENCE ALTERNATE
        String chromosome = variant.getChromosome();
        VariantProto.VariantType type = variant.getType();
        Map<Integer, Character> referenceAlleles = buildReferenceAllelesMap(studyEntry.getFilesList().stream()
                .map(fileEntry -> fileEntry.getCall()==null?null:fileEntry.getCall().getVariantId()).iterator());
        Pair<Integer, Integer> adjustedStartEndPositions = adjustedVariantStart(variant, studyEntry.getSecondaryAlternatesList(), referenceAlleles);
        int start = adjustedStartEndPositions.getLeft();
        int end = adjustedStartEndPositions.getRight();
        List<String> alleleList = buildAlleles(variant, adjustedStartEndPositions, referenceAlleles);
        boolean isNoVariation = type.equals(VariantProto.VariantType.NO_VARIATION);

        // ID
        String idForVcf = getIdForVcf(variant.getId(), variant.getNamesList());

        // FILTER
        final Set<String> filters = getFilters(fileAttributes);

        // QUAL
        double qual = getQuality(fileAttributes);

        // INFO
        // Cohorts stats and annotations (consequence types and population frequencies)
        ObjectMap attributes = new ObjectMap();

        addCohortStats(studyEntry, attributes);

        // if asked variant annotations are exported
        // (corresponding to the CT and POPFREQ info lines from VCF header)
        if (annotations != null && annotations.size() > 0) {
            addAnnotations(variant, attributes);
        }

        // TODO: Add other file attributes?

        // FORMAT
        // Each variant can have different FORMAT so we need to recalculate the positions.
        final Map<String, Integer> formatPositions = new HashMap<>(studyEntry.getSampleDataKeysList().size());
        for (int i = 0; i < studyEntry.getSampleDataKeysList().size(); i++) {
            formatPositions.put(studyEntry.getSampleDataKeysList().get(i), i);
        }

        // SAMPLES
        BiFunction<String, String, String> getSampleData = (sampleName, id) -> getSampleData(studyEntry, formatPositions, sampleName, id);

        List<Genotype> genotypes = getGenotypes(alleleList, studyEntry.getSampleDataKeysList(), getSampleData);

        return makeVariantContext(chromosome, start, end, idForVcf, alleleList, isNoVariation, filters, qual, attributes, genotypes);
    }

    public String getSampleData(VariantProto.StudyEntry studyEntry, Map<String, Integer> formatPositions, String sampleName, String field) {
        if (samplePositions.containsKey(sampleName) && formatPositions.containsKey(field)) {
            VariantProto.SampleEntry sample = studyEntry.getSamples(samplePositions.get(sampleName));
            int formatPos = formatPositions.get(field);
            return formatPos < sample.getDataCount() ? sample.getData(formatPos) : null;
        }
        return null;
    }

    /**
     * Adjust start/end if a reference base is required due to an empty allele. All variants are checked due to SecAlts.
     * @param variant {@link VariantProto.Variant} object.
     * @param referenceAlleles
     * @return Pair<Integer, Integer> The adjusted (or same) start/end position e.g. SV and MNV as SecAlt, INDEL, etc.
     */
    protected Pair<Integer, Integer> adjustedVariantStart(VariantProto.Variant variant,
                                                          List<VariantProto.AlternateCoordinate> secAlts,
                                                          Map<Integer, Character> referenceAlleles) {
        if (variant.getType().equals(VariantProto.VariantType.NO_VARIATION)) {
            return new ImmutablePair<>(variant.getStart(), variant.getEnd());
        }
        MutablePair<Integer, Integer> pos = adjustedVariantStart(variant.getStart(), variant.getEnd(), variant.getReference(), variant.getAlternate(), referenceAlleles, null);

        for (VariantProto.AlternateCoordinate alternateCoordinate: secAlts) {
            adjustedVariantStart(alternateCoordinate.getStart(), alternateCoordinate.getEnd(), alternateCoordinate.getReference(), alternateCoordinate.getAlternate(), referenceAlleles, pos);
        }

        return pos;
    }

    @Override
    public List<String> buildAlleles(VariantProto.Variant variant,
                                     Pair<Integer, Integer> adjustedRange, Map<Integer, Character> referenceAlleles) {
        String reference = variant.getReference();
        String alternate = variant.getAlternate();
        if (variant.getType() == VariantProto.VariantType.TANDEM_DUPLICATION && alternate.equals(VariantBuilder.DUP_ALT)) {
            alternate = VariantBuilder.DUP_TANDEM_ALT;
        }
        List<VariantProto.AlternateCoordinate> secAlts = getStudy(variant).getSecondaryAlternatesList();

        List<String> alleles = new ArrayList<>(secAlts.size() + 2);
        int origStart = variant.getStart();
        int origEnd;
        if (variant.getLength() == Variant.UNKNOWN_LENGTH) {
            origEnd = variant.getStart() + variant.getReference().length() - 1;
        } else {
            origEnd = variant.getEnd();
        }

        alleles.add(buildAllele(variant.getChromosome(), origStart, origEnd, reference, adjustedRange, referenceAlleles));
        alleles.add(buildAllele(variant.getChromosome(), origStart, origEnd, alternate, adjustedRange, referenceAlleles));
        for (VariantProto.AlternateCoordinate alt : secAlts) {
            alleles.add(buildAllele(variant.getChromosome(), alt.getStart(), alt.getEnd(), alt.getAlternate(), adjustedRange, referenceAlleles));
        }
        return alleles;
    }

    private void addCohortStats(VariantProto.StudyEntry studyEntry, Map<String, Object> attributes) {
        if (studyEntry.getStatsCount() == 0) {
            return;
        }

        List<String> statsList = new ArrayList<>();
        for (VariantProto.VariantStats stats : studyEntry.getStatsList()) {
            String cohortId = stats.getCohortId();
//            if (cohortId.equals(StudyEntry.DEFAULT_COHORT)) {
//                int an = stats.getAlleleCount();
//                if (an >= 0) {
//                    attributes.put(cohortId + VCFConstants.ALLELE_NUMBER_KEY, String.valueOf(an));
//                }
//                if (stats.getAltAlleleCount() >= 0) {
//                    attributes.put(cohortId + VCFConstants.ALLELE_COUNT_KEY, String.valueOf(stats.getAltAlleleCount()));
//                }
//            }
            statsList.add(cohortId + ":" + DECIMAL_FORMAT_7.format(stats.getAltAlleleFreq()));
        }
        // set cohort stats attributes
        attributes.put(STATS_INFO_KEY, String.join(FIELD_SEPARATOR, statsList));
    }

    private void addAnnotations(VariantProto.Variant variant, Map<String, Object> attributes) {
        if (variant.getAnnotation() == null) {
            return;
        }

        // consequence type
        if (variant.getAnnotation().getConsequenceTypesList() != null && !variant.getAnnotation().getConsequenceTypesList().isEmpty()) {
            List<String> ctList = new ArrayList<>();
            StringBuilder stringBuilder = new StringBuilder();
            for (int i = 0; i < variant.getAnnotation().getConsequenceTypesCount(); i++) {
                VariantAnnotationProto.ConsequenceType consequenceType = variant.getAnnotation().getConsequenceTypes(i);
                stringBuilder.delete(0, stringBuilder.length());
                // allele
                stringBuilder.append(variant.getAlternate());
                stringBuilder.append(FIELD_SEPARATOR);
                // gene name
                if (consequenceType.getGeneName() != null) {
                    stringBuilder.append(consequenceType.getGeneName());
                }
                stringBuilder.append(FIELD_SEPARATOR);
                // ensembl gene
                if (consequenceType.getEnsemblGeneId() != null) {
                    stringBuilder.append(consequenceType.getEnsemblGeneId());
                }
                stringBuilder.append(FIELD_SEPARATOR);
                // ensembl transcript
                if (consequenceType.getEnsemblTranscriptId() != null) {
                    stringBuilder.append(consequenceType.getEnsemblTranscriptId());
                }
                stringBuilder.append(FIELD_SEPARATOR);
                // biotype
                if (consequenceType.getBiotype() != null) {
                    stringBuilder.append(consequenceType.getBiotype());
                }
                stringBuilder.append(FIELD_SEPARATOR);
                // consequenceType
                stringBuilder.append(consequenceType.getSequenceOntologyTermsList().stream()
                        .map(VariantAnnotationProto.SequenceOntologyTerm::getName)
                        .collect(Collectors.joining(",")));
                stringBuilder.append(FIELD_SEPARATOR);

                // protein position
                if (consequenceType.getProteinVariantAnnotation() != null && consequenceType.getProteinVariantAnnotation().getPosition() > 0) {
                    stringBuilder.append(consequenceType.getProteinVariantAnnotation().getPosition());
                    stringBuilder.append(FIELD_SEPARATOR);
                    stringBuilder.append(consequenceType.getProteinVariantAnnotation().getReference())
                            .append("/")
                            .append(consequenceType.getProteinVariantAnnotation().getAlternate());
                    stringBuilder.append(FIELD_SEPARATOR);
                    if (consequenceType.getProteinVariantAnnotation().getSubstitutionScoresList() != null) {
                        List<String> sift = consequenceType.getProteinVariantAnnotation().getSubstitutionScoresList().stream()
                                .filter(t -> t.getSource().equalsIgnoreCase("sift"))
                                .map(VariantAnnotationProto.Score::getDescription)
                                .collect(Collectors.toList());
                        if (sift.size() > 0) {
                            stringBuilder.append(sift.get(0));
                        }
                        stringBuilder.append(FIELD_SEPARATOR);

                        List<String> polyphen = consequenceType.getProteinVariantAnnotation().getSubstitutionScoresList().stream()
                                .filter(t -> t.getSource().equalsIgnoreCase("polyphen"))
                                .map(VariantAnnotationProto.Score::getDescription)
                                .collect(Collectors.toList());
                        if (polyphen.size() > 0) {
                            stringBuilder.append(polyphen.get(0));
                        }
                        stringBuilder.append(FIELD_SEPARATOR);
                    }
                } else {
                    // We need to add four '|'
                    stringBuilder.append(FIELD_SEPARATOR).append(FIELD_SEPARATOR).append(FIELD_SEPARATOR).append(FIELD_SEPARATOR);
                }

                // add to ct list
                ctList.add(stringBuilder.toString());
            }

            // set consequence type attributes
            attributes.put(ANNOTATION_INFO_KEY, String.join(INFO_SEPARATOR, ctList));
        }

        // population frequencies
        List<VariantAnnotationProto.PopulationFrequency> populationFrequencies = variant.getAnnotation()
                .getPopulationFrequenciesList();
        if (populationFrequencies != null && !populationFrequencies.isEmpty()) {
            List<String> popFreqList = new ArrayList<>();
            for (VariantAnnotationProto.PopulationFrequency pf: populationFrequencies) {
                popFreqList.add(pf.getStudy() + "_" + pf.getPopulation() + ":" + DECIMAL_FORMAT_7.format(pf.getAltAlleleFreq()));
            }
            // set population frequency attributes
            attributes.put(POPFREQ_INFO_KEY, String.join(FIELD_SEPARATOR, popFreqList));
        }
    }

    @Override
    protected VariantProto.StudyEntry getStudy(VariantProto.Variant variant) {
        VariantProto.StudyEntry studyEntry = null;
        for (int i = 0; i < variant.getStudiesCount(); i++) {
//            if (this.studyIdString.equals(studyNameMap.get(variant.getStudies(i).getStudyId()))) {
            if (variant.getStudies(i).getStudyId().equals(this.studyNameMap.get(this.studyIdString))) {
                studyEntry = variant.getStudies(i);
                break;
            }
        }
        return studyEntry;
    }

    @Override
    protected Iterator<String> getStudiesId(VariantProto.Variant variant) {
        return variant.getStudiesList().stream().map(VariantProto.StudyEntry::getStudyId).iterator();
    }

/*
    @Override
    public VariantContext from(VariantProto.Variant variant) {
        VariantContextBuilder variantContextBuilder = new VariantContextBuilder();
        int start = variant.getStart();
        int end = variant.getEnd();
        String reference = variant.getReference();
        String alternate = variant.getAlternate();

        VariantProto.VariantType type = variant.getType();
        if (type == VariantProto.VariantType.INDEL) {
            reference = "N" + reference;
            alternate = "N" + alternate;
            start -= 1; // adjust start
        }

        String filter = "PASS";
        String prk = studyId + "_PR";
        String crk = studyId + "_CR";
        String oprk = studyId + "_OPR";

        //Attributes for INFO column
        ObjectMap attributes = new ObjectMap();

        List<String> allelesArray = Arrays.asList(reference, alternate);  // TODO jmmut: multiallelic
        ArrayList<Genotype> genotypes = new ArrayList<>();
        Integer originalPosition = null;
        List<String> originalAlleles = null;
        for (VariantProto.StudyEntry studyEntry : variant.getStudiesList()) {
            String[] ori = getOri(studyEntry);
            Integer auxOriginalPosition = getOriginalPosition(ori);
            if (originalPosition != null && auxOriginalPosition != null && !originalPosition.equals(auxOriginalPosition)) {
                throw new IllegalStateException("Two or more VariantSourceEntries have different origin. Unable to merge");
            }
            originalPosition = auxOriginalPosition;
            originalAlleles = getOriginalAlleles(ori);
            if (originalAlleles == null) {
                originalAlleles = allelesArray;
            }

            //Only print those variants in which the alternate is the first alternate from the multiallelic alternatives
            if (originalAlleles.size() > 2 && !"0".equals(getOriginalAlleleIndex(ori))) {
                logger.debug("Skip multi allelic variant! " + variant);
                return null;
            }

            // TODO: check getAttributes, getOrderedSamplesName and getSampleData for proto
            try {
                String sourceFilter = studyEntry.getFiles(0).getAttributesOrDefault("FILTER", ".");
                if (sourceFilter != null && !filter.equals(sourceFilter)) {
                    filter = ".";   // write PASS iff all sources agree that the filter is "PASS" or assumed if not present, otherwise write "."
                }
            } catch (Exception e) {
                filter = ".";
            }

            attributes.putIfNotNull(prk, studyEntry.getFiles(0).getAttributes().get("PR"));
            attributes.putIfNotNull(crk, studyEntry.getFiles(0).getAttributes().get("CR"));
            attributes.putIfNotNull(oprk, studyEntry.getFiles(0).getAttributes().get("OPR"));

//            for (VariantProto.StudyEntry.SamplesDataInfoEntry sample: studyEntry.getSamplesDataList()) {
//                String gtStr = sample.getInfo(0); // studyEntry.getSampleData(sampleName, "GT");
//                String genotypeFilter = null; // studyEntry.getSampleData(sampleName, "FT");
//
//                if (gtStr != null) {
//                    List<String> gtSplit = new ArrayList<>(Arrays.asList(gtStr.split(",")));
//                    List<String> ftSplit = new ArrayList<>(Arrays.asList(
//                            (StringUtils.isBlank(genotypeFilter) ? "" : genotypeFilter).split(",")));
//                    boolean filterIsMatching = gtSplit.size() == ftSplit.size();
//                    while (gtSplit.size() > 1) {
//                        int idx = gtSplit.indexOf(".");
//                        if (idx < 0) {
//                            idx = gtSplit.indexOf("0/0");
//                        }
//                        if (idx < 0) {
//                            break;
//                        }
//                        gtSplit.remove(idx);
//                        ftSplit.remove(idx);
//                    }
//                    String gt = gtSplit.get(0);
//                    String ft = ftSplit.get(0);
//
//                    org.opencb.biodata.models.variant.Genotype genotype =
//                            new org.opencb.biodata.models.variant.Genotype(gt, reference, alternate);
//                    List<Allele> alleles = new ArrayList<>();
//                    for (int gtIdx : genotype.getAllelesIdx()) {
//                        if (gtIdx < originalAlleles.size() && gtIdx >= 0) {
//                            alleles.add(Allele.create(originalAlleles.get(gtIdx), gtIdx == 0)); // allele is ref. if the alleleIndex is 0
//                        } else {
//                            alleles.add(Allele.create(".", false)); // genotype of a secondary alternate, or an actual missing
//                        }
//                    }
//
//                    if (StringUtils.isBlank(ft)) {
//                        genotypeFilter = null;
//                    } else if (StringUtils.equals("PASS", ft)) {
//                        genotypeFilter = "1";
//                    } else {
//                        genotypeFilter = "0";
//                    }


text:
package com.trello.qa26.fw;

import com.trello.qa26.model.User;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class UserHelper extends HelperBase{

    public UserHelper(WebDriver wd) {
        super(wd);
    }

    public void initLogin() {
        click(By.cssSelector("[href='/login']"));

    }

    public void fillLoginForm(User user) throws InterruptedException {
        type(By.id("user"), user.getEmail());
        pause(2000);
        click(By.id("login"));
        type(By.id("password"), user.getPassword());

    }

    public void confirmLogin() {
        click(By.id("login-submit"));
    }

    public boolean isAvatarPresent() throws InterruptedException {
        pause(20000);
        return isElementPresent(By.cssSelector("[data-test-id='header-member-menu-button']"));
    }

    public void logIn() throws InterruptedException {
       click(By.cssSelector("[href='/login']"));
        fillLoginForm(new User().setEmail("yrosenblum1994@gmail.com").setPassword("rosenblum94"));
        pause(2000);
        click(By.cssSelector("#login-submit"));

    }

    public void cliackOnTheAvatar() {
        click(By.cssSelector("[data-test-id='header-member-menu-button']"));
    }

    public void goToProfile() {
        click(By.cssSelector("[data-test-id='header-member-menu-profile']"));
    }

    public void goToAtlasianAcc() {
      //  System.out.println(wd.getWindowHandles());
        click(By.cssSelector("[href$=manage-profile]"));
        swichToWindowHanleIndex(1);

    }
    public void closeWindow(){
        wd.close();
        swichToWindowHanleIndex(0);
    }

    public void changeAvatar (String path) throws InterruptedException {
        Actions actions = new Actions(wd);
        actions.moveToElement(wd.findElement(By.cssSelector("[data-test-selector='profile-hover-info']")))
                .moveToElement(wd.findElement(By.cssSelector("[data-test-selector='profile-hover-info'] [class^=Droplist__Trigger]")))
                //.moveToElement(wd.findElement(By.xpath(".//*[@class='Droplist__Trigger-sc-1z05y4v-3 eteVrT']")))
                .click()
                .perform();
        //click(By.xpath("//div[@id='uid16']/span[1]"));
         click(By.xpath("//div[@class='sc-iuJeZd gyunVU']/span[1]"));
         pause(1000);

        attachPhoto(By.cssSelector("#image-input"), new File(path));
        pause(1000);
        clickXpath("//div[@class='sc-cNnxps eYeGXT']/button[1]");

    }

}


text:
/*
 * SPDX-License-Identifier: Apache-2.0
 *
 * The OpenSearch Contributors require contributions made to
 * this file be licensed under the Apache-2.0 license or a
 * compatible open source license.
 */

/*
 * Licensed to Elasticsearch under one or more contributor
 * license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright
 * ownership. Elasticsearch 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.
 */

/*
 * Modifications Copyright OpenSearch Contributors. See
 * GitHub history for details.
 */

package org.opensearch.ingest.geoip;

import com.maxmind.db.NoCache;
import com.maxmind.db.NodeCache;
import com.maxmind.db.Reader;
import com.maxmind.geoip2.DatabaseReader;
import com.maxmind.geoip2.model.AbstractResponse;
import org.opensearch.common.Booleans;
import org.opensearch.common.SuppressForbidden;
import org.opensearch.common.cache.Cache;
import org.opensearch.common.cache.CacheBuilder;
import org.opensearch.common.io.PathUtils;
import org.opensearch.common.settings.Setting;
import org.opensearch.core.internal.io.IOUtils;
import org.opensearch.ingest.Processor;
import org.opensearch.plugins.IngestPlugin;
import org.opensearch.plugins.Plugin;

import java.io.Closeable;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Stream;

public class IngestGeoIpPlugin extends Plugin implements IngestPlugin, Closeable {
    public static final Setting<Long> CACHE_SIZE = Setting.longSetting("ingest.geoip.cache_size", 1000, 0, Setting.Property.NodeScope);

    static String[] DEFAULT_DATABASE_FILENAMES = new String[] { "GeoLite2-ASN.mmdb", "GeoLite2-City.mmdb", "GeoLite2-Country.mmdb" };

    private Map<String, DatabaseReaderLazyLoader> databaseReaders;

    @Override
    public List<Setting<?>> getSettings() {
        return Arrays.asList(CACHE_SIZE);
    }

    @Override
    public Map<String, Processor.Factory> getProcessors(Processor.Parameters parameters) {
        if (databaseReaders != null) {
            throw new IllegalStateException("getProcessors called twice for geoip plugin!!");
        }
        final Path geoIpDirectory = getGeoIpDirectory(parameters);
        final Path geoIpConfigDirectory = parameters.env.configDir().resolve("ingest-geoip");
        long cacheSize = CACHE_SIZE.get(parameters.env.settings());
        try {
            databaseReaders = loadDatabaseReaders(geoIpDirectory, geoIpConfigDirectory);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return Collections.singletonMap(GeoIpProcessor.TYPE, new GeoIpProcessor.Factory(databaseReaders, new GeoIpCache(cacheSize)));
    }

    /*
     * In GeoIpProcessorNonIngestNodeTests, ingest-geoip is loaded on the classpath. This means that the plugin is never unbundled into a
     * directory where the database files would live. Therefore, we have to copy these database files ourselves. To do this, we need the
     * ability to specify where those database files would go. We do this by adding a plugin that registers ingest.geoip.database_path as
     * an actual setting. Otherwise, in production code, this setting is not registered and the database path is not configurable.
     */
    @SuppressForbidden(reason = "PathUtils#get")
    private Path getGeoIpDirectory(Processor.Parameters parameters) {
        final Path geoIpDirectory;
        if (parameters.env.settings().get("ingest.geoip.database_path") == null) {
            geoIpDirectory = parameters.env.modulesDir().resolve("ingest-geoip");
        } else {
            geoIpDirectory = PathUtils.get(parameters.env.settings().get("ingest.geoip.database_path"));
        }
        return geoIpDirectory;
    }

    static Map<String, DatabaseReaderLazyLoader> loadDatabaseReaders(Path geoIpDirectory, Path geoIpConfigDirectory) throws IOException {
        assertDatabaseExistence(geoIpDirectory, true);
        assertDatabaseExistence(geoIpConfigDirectory, false);
        final boolean loadDatabaseOnHeap = Booleans.parseBoolean(System.getProperty("opensearch.geoip.load_db_on_heap", "false"));
        final Map<String, DatabaseReaderLazyLoader> databaseReaders = new HashMap<>();

        // load the default databases
        for (final String databaseFilename : DEFAULT_DATABASE_FILENAMES) {
            final Path databasePath = geoIpDirectory.resolve(databaseFilename);
            final DatabaseReaderLazyLoader loader = createLoader(databasePath, loadDatabaseOnHeap);
            databaseReaders.put(databaseFilename, loader);
        }

        // load any custom databases
        if (Files.exists(geoIpConfigDirectory)) {
            try (Stream<Path> databaseFiles = Files.list(geoIpConfigDirectory)) {
                PathMatcher pathMatcher = geoIpConfigDirectory.getFileSystem().getPathMatcher("glob:**.mmdb");
                // Use iterator instead of forEach otherwise IOException needs to be caught twice...
                Iterator<Path> iterator = databaseFiles.iterator();
                while (iterator.hasNext()) {
                    Path databasePath = iterator.next();
                    if (Files.isRegularFile(databasePath) && pathMatcher.matches(databasePath)) {
                        String databaseFileName = databasePath.getFileName().toString();
                        final DatabaseReaderLazyLoader loader = createLoader(databasePath, loadDatabaseOnHeap);
                        databaseReaders.put(databaseFileName, loader);
                    }
                }
            }
        }
        return Collections.unmodifiableMap(databaseReaders);
    }

    private static DatabaseReaderLazyLoader createLoader(Path databasePath, boolean loadDatabaseOnHeap) {
        return new DatabaseReaderLazyLoader(databasePath, () -> {
            DatabaseReader.Builder builder = createDatabaseBuilder(databasePath).withCache(NoCache.getInstance());
            if (loadDatabaseOnHeap) {
                builder.fileMode(Reader.FileMode.MEMORY);
            } else {
                builder.fileMode(Reader.FileMode.MEMORY_MAPPED);
            }
            return builder.build();
        });
    }

    private static void assertDatabaseExistence(final Path path, final boolean exists) throws IOException {
        for (final String database : DEFAULT_DATABASE_FILENAMES) {
            if (Files.exists(path.resolve(database)) != exists) {
                final String message = "expected database [" + database + "] to " + (exists ? "" : "not ") + "exist in [" + path + "]";
                throw new IOException(message);
            }
        }
    }

    @SuppressForbidden(reason = "Maxmind API requires java.io.File")
    private static DatabaseReader.Builder createDatabaseBuilder(Path databasePath) {
        return new DatabaseReader.Builder(databasePath.toFile());
    }

    @Override
    public void close() throws IOException {
        if (databaseReaders != null) {
            IOUtils.close(databaseReaders.values());
        }
    }

    /**
     * The in-memory cache for the geoip data. There should only be 1 instance of this class..
     * This cache differs from the maxmind's {@link NodeCache} such that this cache stores the deserialized Json objects to avoid the
     * cost of deserialization for each lookup (cached or not). This comes at slight expense of higher memory usage, but significant
     * reduction of CPU usage.
     */
    static class GeoIpCache {
        private final Cache<CacheKey<?>, AbstractResponse> cache;

        // package private for testing
        GeoIpCache(long maxSize) {
            if (maxSize < 0) {
                throw new IllegalArgumentException("geoip max cache size must be 0 or greater");
            }
            this.cache = CacheBuilder.<CacheKey<?>, AbstractResponse>builder().setMaximumWeight(maxSize).build();
        }

        <T extends AbstractResponse> T putIfAbsent(
            InetAddress ip,
            Class<T> responseType,
            Function<InetAddress, AbstractResponse> retrieveFunction
        ) {

            // can't use cache.computeIfAbsent due to the elevated permissions for the jackson (run via the cache loader)
            CacheKey<T> cacheKey = new CacheKey<>(ip, responseType);
            // intentionally non-locking for simplicity...it's OK if we re-put the same key/value in the cache during a race condition.
            AbstractResponse response = cache.get(cacheKey);
            if (response == null) {
                response = retrieveFunction.apply(ip);
                cache.put(cacheKey, response);
            }
            return responseType.cast(response);
        }

        // only useful for testing
        <T extends AbstractResponse> T get(InetAddress ip, Class<T> responseType) {
            CacheKey<T> cacheKey = new CacheKey<>(ip, responseType);
            return responseType.cast(cache.get(cacheKey));
        }

        /**
        * The key to use for the cache. Since this cache can span multiple geoip processors that all use different databases, the response
        * type is needed to be included in the cache key. For example, if we only used the IP address as the key the City and ASN the same
        * IP may be in both with different values and we need to cache both. The response type scopes the IP to the correct database
        * provides a means to safely cast the return objects.
        * @param <T> The AbstractResponse type used to scope the key and cast the result.
        */
        private static class CacheKey<T extends AbstractResponse> {

            private final InetAddress ip;
            private final Class<T> responseType;

            private CacheKey(InetAddress ip, Class<T> responseType) {
                this.ip = ip;
                this.responseType = responseType;
            }

            // generated
            @Override
            public boolean equals(Object o) {
                if (this == o) return true;
                if (o == null || getClass() != o.getClass()) return false;
                CacheKey<?> cacheKey = (CacheKey<?>) o;
                return Objects.equals(ip, cacheKey.ip) && Objects.equals(responseType, cacheKey.responseType);
            }

            // generated
            @Override
            public int hashCode() {
                return Objects.hash(ip, responseType);
            }
        }
    }
}


text:
package com.example.android.newsappstage2;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see Testing documentation
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getTargetContext();

        assertEquals("com.example.android.newsappstage2", appContext.getPackageName());
    }
}


text:
/*
 * Copyright (c) 2014 DataTorrent, Inc. ALL Rights Reserved.
 *
 * 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
 *
 *   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 com.datatorrent.contrib.aerospike;

import com.aerospike.client.AerospikeClient;
import com.aerospike.client.AerospikeException;
import com.aerospike.client.Bin;
import com.aerospike.client.Key;
import com.aerospike.client.Record;
import com.aerospike.client.query.RecordSet;
import com.aerospike.client.query.Statement;
import com.datatorrent.api.AttributeMap;
import com.datatorrent.api.DAG;
import com.datatorrent.lib.helper.OperatorContextTestHelper;
import com.datatorrent.lib.testbench.CollectorTestSink;
import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.Test;
import java.util.List;

/**
 * Tests for {@link AbstractAerosipkeTransactionalPutOperator} and {@link AbstractAerospikeGetOperator}
 */
public class AerospikeOperatorTest {

  public static final String NODE = "127.0.0.1";
  public static final String NAMESPACE = "test";
  public static final int PORT = 3000;

  private static final String SET_NAME = "test_event_set";
  private static String APP_ID = "AerospikeOperatorTest";
  private static int OPERATOR_ID = 0;

  private static class TestEvent {

    int id;

    TestEvent(int id) {
      this.id = id;
    }
  }

  private static void cleanTable() {

    try {
      AerospikeClient client = new AerospikeClient(NODE, PORT);

      Statement stmnt = new Statement();
      stmnt.setNamespace(NAMESPACE);
      stmnt.setSetName(SET_NAME);

      RecordSet rs = client.query(null, stmnt);
      while(rs.next()){
        client.delete(null, rs.getKey());
      }
    }
    catch (AerospikeException e) {
      throw new RuntimeException(e);
    }
  }

  private static class TestOutputOperator extends AbstractAerospikeTransactionalPutOperator<TestEvent> {

    TestOutputOperator() {
      cleanTable();
    }

    public long getNumOfEventsInStore() {
      try {
        int count =0;
        AerospikeClient client = new AerospikeClient(NODE, PORT);
        Statement stmnt = new Statement();
        stmnt.setNamespace(NAMESPACE);
        stmnt.setSetName(SET_NAME);

        RecordSet rs = client.query(null, stmnt);
        while(rs.next()){
          count++;
        }
        return count;
      }
      catch (AerospikeException e) {
        throw new RuntimeException("fetching count", e);
      }
    }

    @Override
    protected Key getUpdatedBins(TestEvent tuple, List<Bin> bins)
        throws AerospikeException {
      Key key = new Key(NAMESPACE,SET_NAME,String.valueOf(tuple.id));
      bins.add(new Bin("ID",tuple.id));
      return key;
    }
  }

  private static class TestInputOperator extends AbstractAerospikeGetOperator<TestEvent> {

    TestInputOperator() {
      cleanTable();
    }

    @Override
    public TestEvent getTuple(Record record) {

      return new TestEvent((Integer) record.getValue("ID"));
    }

    @Override
    public Statement queryToRetrieveData() {

      Statement stmnt = new Statement();
      stmnt.setNamespace(NAMESPACE);
      stmnt.setSetName(SET_NAME);

      return stmnt;
    }

    public void insertEventsInTable(int numEvents) {

      try {
        AerospikeClient client = new AerospikeClient(NODE, PORT);
        Key key;
        Bin bin;
        for (int i = 0; i < numEvents; i++) {
          key = new Key(NAMESPACE,SET_NAME,String.valueOf(i));
          bin = new Bin("ID",i);
          client.put(null, key, bin);
        }
      }
      catch (AerospikeException e) {
        throw new RuntimeException(e);
      }
    }

  }

  @Test
  public void TestAerospikeOutputOperator() {

    AerospikeTransactionalStore transactionalStore = new AerospikeTransactionalStore();
    transactionalStore.setNode(NODE);
    transactionalStore.setPort(PORT);
    transactionalStore.setNamespace(NAMESPACE);

    AttributeMap.DefaultAttributeMap attributeMap = new AttributeMap.DefaultAttributeMap();
    attributeMap.put(DAG.APPLICATION_ID, APP_ID);
    OperatorContextTestHelper.TestIdOperatorContext context = new OperatorContextTestHelper.TestIdOperatorContext(OPERATOR_ID, attributeMap);

    TestOutputOperator outputOperator = new TestOutputOperator();

    outputOperator.setStore(transactionalStore);

    outputOperator.setup(context);

    List<TestEvent> events = Lists.newArrayList();
    for (int i = 0; i < 10; i++) {
      events.add(new TestEvent(i));
    }

    outputOperator.beginWindow(0);
    for (TestEvent event : events) {
      outputOperator.input.process(event);
    }
    outputOperator.endWindow();

    Assert.assertEquals("rows in db", 10, outputOperator.getNumOfEventsInStore());
  }

  @Test
  public void TestAerospikeInputOperator() {

    AerospikeStore store = new AerospikeStore();
    store.setNode(NODE);
    store.setPort(PORT);

    AttributeMap.DefaultAttributeMap attributeMap = new AttributeMap.DefaultAttributeMap();
    attributeMap.put(DAG.APPLICATION_ID, APP_ID);
    OperatorContextTestHelper.TestIdOperatorContext context = new OperatorContextTestHelper.TestIdOperatorContext(OPERATOR_ID, attributeMap);

    TestInputOperator inputOperator = new TestInputOperator();
    inputOperator.setStore(store);
    inputOperator.insertEventsInTable(10);

    CollectorTestSink<Object> sink = new CollectorTestSink<Object>();
    inputOperator.outputPort.setSink(sink);

    inputOperator.setup(context);
    inputOperator.beginWindow(0);
    inputOperator.emitTuples();
    inputOperator.endWindow();

    Assert.assertEquals("rows from db", 10, sink.collectedTuples.size());
  }

}


text:
/*
 * Copyright 2020 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.
 */
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/compute/v1/compute.proto

package com.google.cloud.compute.v1;

public interface ResourcePolicyHourlyCycleOrBuilder
    extends
    // @@protoc_insertion_point(interface_extends:google.cloud.compute.v1.ResourcePolicyHourlyCycle)
    com.google.protobuf.MessageOrBuilder {

  /**
   *
   *
   *

   * [Output only] Duration of the time window, automatically chosen to be smallest possible in the given scenario.
   *

   *
   * optional string duration = 155471252;
   *
   * @return Whether the duration field is set.
   */
  boolean hasDuration();
  /**
   *
   *
   *

   * [Output only] Duration of the time window, automatically chosen to be smallest possible in the given scenario.
   *

   *
   * optional string duration = 155471252;
   *
   * @return The duration.
   */
  java.lang.String getDuration();
  /**
   *
   *
   *

   * [Output only] Duration of the time window, automatically chosen to be smallest possible in the given scenario.
   *

   *
   * optional string duration = 155471252;
   *
   * @return The bytes for duration.
   */
  com.google.protobuf.ByteString getDurationBytes();

  /**
   *
   *
   *

   * Defines a schedule with units measured in hours. The value determines how many hours pass between the start of each cycle.
   *

   *
   * optional int32 hours_in_cycle = 526763132;
   *
   * @return Whether the hoursInCycle field is set.
   */
  boolean hasHoursInCycle();
  /**
   *
   *
   *

   * Defines a schedule with units measured in hours. The value determines how many hours pass between the start of each cycle.
   *

   *
   * optional int32 hours_in_cycle = 526763132;
   *
   * @return The hoursInCycle.
   */
  int getHoursInCycle();

  /**
   *
   *
   *

   * Time within the window to start the operations. It must be in format "HH:MM", where HH : [00-23] and MM : [00-00] GMT.
   *

   *
   * optional string start_time = 37467274;
   *
   * @return Whether the startTime field is set.
   */
  boolean hasStartTime();
  /**
   *
   *
   *

   * Time within the window to start the operations. It must be in format "HH:MM", where HH : [00-23] and MM : [00-00] GMT.
   *

   *
   * optional string start_time = 37467274;
   *
   * @return The startTime.
   */
  java.lang.String getStartTime();
  /**
   *
   *
   *

   * Time within the window to start the operations. It must be in format "HH:MM", where HH : [00-23] and MM : [00-00] GMT.
   *

   *
   * optional string start_time = 37467274;
   *
   * @return The bytes for startTime.
   */
  com.google.protobuf.ByteString getStartTimeBytes();
}


text:
/*
 **********************************************************************
 * Copyright (c) 2019 Contributors to the Eclipse Foundation
 *
 * See the NOTICES file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * 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
 *
 *     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.
 *
 * SPDX-License-Identifier: Apache-2.0
 **********************************************************************/
package org.eclipse.microprofile.metrics.tck.tags;

import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Gauge;

import jakarta.enterprise.context.ApplicationScoped;

@ApplicationScoped
public class GaugeTagMethodBean {

    private long gaugeOne;
    private long gaugeTwo;

    @Gauge(name = "gaugeMethod", unit = MetricUnits.NONE, tags = {"number=one"})
    public long getGaugeOne() {
        return gaugeOne;
    }

    @Gauge(name = "gaugeMethod", unit = MetricUnits.NONE, tags = {"number=two"})
    public long getGaugeTwo() {
        return gaugeTwo;
    }

    public void setGaugeOne(long gauge) {
        this.gaugeOne = gauge;
    }

    public void setGaugeTwo(long gauge) {
        this.gaugeTwo = gauge;
    }
}


text:
package org.opencb.opencga.core.models.analysis.knockout;

public class IndividualKnockoutStats extends KnockoutStats {

    private KnockoutStats missingParents;
    private KnockoutStats singleParent;
    private KnockoutStats bothParents;

    public IndividualKnockoutStats() {
    }

    public IndividualKnockoutStats(KnockoutStats missingParents, KnockoutStats singleParent, KnockoutStats bothParents) {
        super(missingParents.getCount() + singleParent.getCount() + bothParents.getCount(),
                missingParents.getNumHomAlt() + singleParent.getNumHomAlt() + bothParents.getNumHomAlt(),
                missingParents.getNumCompHet() + singleParent.getNumCompHet() + bothParents.getNumCompHet(),
                missingParents.getNumHetAlt() + singleParent.getNumHetAlt() + bothParents.getNumHetAlt(),
                missingParents.getNumDelOverlap() + singleParent.getNumDelOverlap() + bothParents.getNumDelOverlap());
        this.missingParents = missingParents;
        this.singleParent = singleParent;
        this.bothParents = bothParents;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("IndividualStats{");
        sb.append("missingParents=").append(missingParents);
        sb.append(", singleParent=").append(singleParent);
        sb.append(", bothParents=").append(bothParents);
        sb.append('}');
        return sb.toString();
    }

    public KnockoutStats getMissingParents() {
        return missingParents;
    }

    public IndividualKnockoutStats setMissingParents(KnockoutStats missingParents) {
        this.missingParents = missingParents;
        return this;
    }

    public KnockoutStats getSingleParent() {
        return singleParent;
    }

    public IndividualKnockoutStats setSingleParent(KnockoutStats singleParent) {
        this.singleParent = singleParent;
        return this;
    }

    public KnockoutStats getBothParents() {
        return bothParents;
    }

    public IndividualKnockoutStats setBothParents(KnockoutStats bothParents) {
        this.bothParents = bothParents;
        return this;
    }
}


text:
package com.lmt.data.unstructured.util;

/**
 * @author MT-Lin
 * @date 2018/1/7 8:30
 */
public class UdConstant {

    /**
     * 文件扩展名
     */
    public static final String FILE_TYPE_TXT = "txt";
    public static final String FILE_TYPE_XLS = "xls";
    public static final String FILE_TYPE_XLSX = "xlsx";
    public static final String FILE_TYPE_DOC = "doc";
    public static final String FILE_TYPE_DOCX = "docx";
    public static final String FILE_TYPE_PPT = "ppt";
    public static final String FILE_TYPE_PPTX = "pptx";
    public static final String FILE_TYPE_PDF = "pdf";

    /**
     * 文件扩展名分隔符
     */
    public static final String FILE_EXTENSION_SPLIT = ".";

    /**
     * ES索引
     */
    public static final String ES_INDEX = "unstructured_data";

    /**
     * ES节点分隔符
     */
    public static final String CLUSTER_NODES_SPLIT = ",";

    /**
     * ES地址和端口号分隔符
     */
    public static final String ADDRESS_PORT_SPLIT = ":";

    /**
     * EsResponse 成功状态码
     */
    public static final int ES_RESPONSE_SUCCESS = 200;

    /**
     * 收藏操作编码
     */
    public static final int COLLECTION_OPERATION_ADD = 1;

    /**
     * 取消收藏操作编码
     */
    public static final int COLLECTION_OPERATION_CANCEL = -1;

    /**
     * 返回数据为空的请求链接
     */
    public static final String DOWNLOAD_FILE_URL = "/FileApi/download";

    /**
     * 用户登录失败编码
     */
    public static final String LOGIN_FAIL = "009002";

    /**
     * 用户登陆成功编码
     */
    public static final String LOGIN_SUCCESS = "009001";

    /**
     * 待审核的状态编码
     */
    public static final String AUDIT_STATUS_WAIT = "005003";

    /**
     * 审核通过的状态编码
     */
    public static final String AUDIT_STATUS_PASS = "005001";

    /**
     * 新增资源操作的审核编码
     */
    public static final String AUDIT_OPERATION_ADD = "004001";

    /**
     * 删除资源操作的审核编码
     */
    public static final String AUDIT_OPERATION_DELETE = "004002";

    /**
     * 文件流一次读取的长度
     */
    public static final int FILE_READ_BUFFER_SIZE = 3096;

    /**
     * 返回结果编码标识
     */
    public static final String RESULT_CODE = "code";

    /**
     * 返回结果信息标识
     */
    public static final String RESULT_MSG = "msg";

    /**
     * 返回结果数据标识
     */
    public static final String RESULT_DATA = "data";

    /**
     * 操作结果成功编码
     */
    public static final int RESULT_CORRECT_CODE = 3;

    /**
     * 操作结果出错（失败）编码
     */
    public static final int RESULT_ERROR_CODE = 0;

    /**
     * 文件上传保存路径
     */
    public static final String RESOURCE_TEMP = "unstructured.data.resource.upload";

    /**
     * 控件节点的value标识
     */
    public static final String PROPS_VALUE = "value";

    /**
     * 控件节点的ID标识
     */
    public static final String PROPS_ID = "id";

    /**
     * 控件节点的CODE标识
     */
    public static final String PROPS_CODE = "code";

    /**
     * 控件节点属性名称
     */
    public static final String PROPS_CHILDREN = "children";

    /**
     * 控件显示节点名的属性名称
     */
    public static final String PROPS_LABEL = "label";

    /**
     * 存储分页查找数据总数的变量名
     */
    public static final String TOTAL_ELEMENTS = "totalElements";

    /**
     * 存储分页查找结果数据的变量名
     */
    public static final String CONTENT = "content";

    /**
     * 密码错误次数（5次）
     */
    public static final int PASSWORD_ERROR_TIME = 6;

    /**
     * 默认的密码错误次数的值
     */
    public static final int DEFAULT_PASSWORD_ERROR_TIME = 1;

    /**
     * 账户冻结状态码
     */
    public static final String COUNT_FREEZE_CODE = "007002";

    /**
     * 账户正常状态码
     */
    public static final String COUNT_UNFREEZE_CODE = "007001";

    /**
     * 默认密码
     */
    public static final String DEFAULT_PASSWORD = "aaaaaa";

    /**
     * 用户类型（管理员）编码
     */
    public static final String USER_TYPE_ADMIN_CODE = "008001";

    /**
     * 用户类型（普通用户）编码
     */
    public static final String USER_TYPE_USER_CODE = "008002";

    /**
     * 用户登录凭证字段
     */
    public static final String USER_LOGIN_EVIDENCE = "tokenId";

    public static final char[] HEX_CHAR = { '0', '1', '2', '3', '4', '5', '6',
            '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

    public static final String KEY_MD5 = "MD5";

    public static final String CHARSET_ISO88591 = "ISO-8859-1";
}


text:
/*
 * Swagger Petstore
 * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
 *
 * OpenAPI spec version: 1.0.0
 * Contact: apiteam@swagger.io
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */

package io.swagger.model;

import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * Model for testing reserved words
 */
@ApiModel(description = "Model for testing reserved words")

public class ModelReturn   {
  @JsonProperty("return")
  private Integer _return = null;

  public ModelReturn _return(Integer _return) {
    this._return = _return;
    return this;
  }

   /**
   * Get _return
   * @return _return
  **/
  @ApiModelProperty(value = "")
  public Integer getReturn() {
    return _return;
  }

  public void setReturn(Integer _return) {
    this._return = _return;
  }

  @Override
  public boolean equals(java.lang.Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    ModelReturn _return = (ModelReturn) o;
    return Objects.equals(this._return, _return._return);
  }

  @Override
  public int hashCode() {
    return Objects.hash(_return);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class ModelReturn {\n");

    sb.append("    _return: ").append(toIndentedString(_return)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(java.lang.Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }
}


text:
/*
 * Copyright (c) 2016-2017 by OpenText Corporation. All Rights Reserved.
 */
package com.opentext.ia.yaml.configuration;

import com.opentext.ia.yaml.core.Value;
import com.opentext.ia.yaml.core.Visit;
import com.opentext.ia.yaml.core.YamlMap;

class ReplacePdiResultSchemaNamespaceWithUri extends YamlContentVisitor {

  private static final String RESULT_SCHEMA = "result.schema";

  ReplacePdiResultSchemaNamespaceWithUri() {
    super("pdi");
  }

  @Override
  void visitContent(Visit visit, YamlMap content) {
    content.get(DATA).toList().stream()
        .map(Value::toMap)
        .filter(map -> map.containsKey(RESULT_SCHEMA))
        .forEach(map -> replaceResultSchemaNamespaceWithUri(visit.getRootMap(), map));
  }

  private void replaceResultSchemaNamespaceWithUri(YamlMap root, YamlMap data) {
    data.put(RESULT_SCHEMA, NamespaceUri.byPrefix(root, data.get(RESULT_SCHEMA)));
  }

}


text:
/*
 * Copyright (C) 2007-2010 Júlio Vilmar Gesser.
 * Copyright (C) 2011, 2013-2016 The JavaParser Team.
 *
 * This file is part of JavaParser.
 *
 * JavaParser can be used either under the terms of
 * a) the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * b) the terms of the Apache License
 *
 * You should have received a copy of both licenses in LICENCE.LGPL and
 * LICENCE.APACHE. Please refer to those files for details.
 *
 * JavaParser is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 */
package com.github.javaparser.ast.stmt;

import com.github.javaparser.ast.AllFieldsConstructor;
import com.github.javaparser.ast.expr.SimpleName;
import com.github.javaparser.ast.observer.ObservableProperty;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import static com.github.javaparser.utils.Utils.assertNotNull;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.visitor.CloneVisitor;
import com.github.javaparser.metamodel.LabeledStmtMetaModel;
import com.github.javaparser.metamodel.JavaParserMetaModel;
import javax.annotation.Generated;
import com.github.javaparser.TokenRange;
import java.util.function.Consumer;
import java.util.Optional;

/**
 * A statement that is labeled, like label123: println("continuing");
 *
 * @author Julio Vilmar Gesser
 */
public final class LabeledStmt extends Statement {

    private SimpleName label;

    private Statement statement;

    public LabeledStmt() {
        this(null, new SimpleName(), new ReturnStmt());
    }

    public LabeledStmt(final String label, final Statement statement) {
        this(null, new SimpleName(label), statement);
    }

    @AllFieldsConstructor
    public LabeledStmt(final SimpleName label, final Statement statement) {
        this(null, label, statement);
    }

    /**
     * This constructor is used by the parser and is considered private.
     */
    @Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator")
    public LabeledStmt(TokenRange tokenRange, SimpleName label, Statement statement) {
        super(tokenRange);
        setLabel(label);
        setStatement(statement);
        customInitialization();
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.AcceptGenerator")
    public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
        return v.visit(this, arg);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.AcceptGenerator")
    public  void accept(final VoidVisitor v, final A arg) {
        v.visit(this, arg);
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public Statement getStatement() {
        return statement;
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public LabeledStmt setStatement(final Statement statement) {
        assertNotNull(statement);
        if (statement == this.statement) {
            return (LabeledStmt) this;
        }
        notifyPropertyChange(ObservableProperty.STATEMENT, this.statement, statement);
        if (this.statement != null)
            this.statement.setParentNode(null);
        this.statement = statement;
        setAsParentNodeOf(statement);
        return this;
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public SimpleName getLabel() {
        return label;
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public LabeledStmt setLabel(final SimpleName label) {
        assertNotNull(label);
        if (label == this.label) {
            return (LabeledStmt) this;
        }
        notifyPropertyChange(ObservableProperty.LABEL, this.label, label);
        if (this.label != null)
            this.label.setParentNode(null);
        this.label = label;
        setAsParentNodeOf(label);
        return this;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
    public boolean remove(Node node) {
        if (node == null)
            return false;
        return super.remove(node);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.CloneGenerator")
    public LabeledStmt clone() {
        return (LabeledStmt) accept(new CloneVisitor(), null);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.GetMetaModelGenerator")
    public LabeledStmtMetaModel getMetaModel() {
        return JavaParserMetaModel.labeledStmtMetaModel;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator")
    public boolean replace(Node node, Node replacementNode) {
        if (node == null)
            return false;
        if (node == label) {
            setLabel((SimpleName) replacementNode);
            return true;
        }
        if (node == statement) {
            setStatement((Statement) replacementNode);
            return true;
        }
        return super.replace(node, replacementNode);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public boolean isLabeledStmt() {
        return true;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public LabeledStmt asLabeledStmt() {
        return this;
    }

    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public void ifLabeledStmt(Consumer<LabeledStmt> action) {
        action.accept(this);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public Optional<LabeledStmt> toLabeledStmt() {
        return Optional.of(this);
    }
}