package org.javarosa.core.model.utils;

import org.javarosa.core.model.trace.EvaluationTrace;
import org.javarosa.core.model.trace.EvaluationTraceReporter;
import org.javarosa.core.model.trace.StringEvaluationTraceSerializer;

/**
 * Utility functions for instrumentation in the engine
 *
 * Created by ctsims on 7/6/2017.
 */

public class InstrumentationUtils {

    /**
     * Prints out traces (if any exist) from the provided reporter with a description into sysout
     */
    public static void printAndClearTraces(EvaluationTraceReporter reporter, String description) {
        if (reporter != null) {
            if (reporter.wereTracesReported()) {
                System.out.println(description);
            }

            StringEvaluationTraceSerializer serializer = new StringEvaluationTraceSerializer();

            for (EvaluationTrace trace : reporter.getCollectedTraces()) {
                System.out.println(trace.getExpression() + ": " + trace.getValue());
                System.out.print(serializer.serializeEvaluationLevels(trace));
            }

            reporter.reset();
        }
    }
}

package org.javarosa.core.model.utils;

import org.javarosa.core.model.trace.EvaluationTrace;
import org.javarosa.core.model.trace.EvaluationTraceReporter;
import org.javarosa.core.model.trace.StringEvaluationTraceSerializer;

/**
 * Utility functions for instrumentation in the engine
 *
 * Created by ctsims on 7/6/2017.
 */

public class InstrumentationUtils {

    /**
     * Prints out traces (if any exist) from the provided reporter with a description into sysout
     */
    public static void printAndClearTraces(EvaluationTraceReporter reporter, String description) {
        if (reporter != null) {
            if (reporter.wereTracesReported()) {
                System.out.println(description);
            }

            StringEvaluationTraceSerializer serializer = new StringEvaluationTraceSerializer();

            for (EvaluationTrace trace : reporter.getCollectedTraces()) {
                System.out.println(trace.getExpression() + ": " + trace.getValue());
                System.out.print(serializer.serializeEvaluationLevels(trace));
            }

            reporter.reset();
        }
    }

    /**
     * Prints out traces (if any exist) from the provided reporter with a description into sysout
     */
    public static String collectAndClearTraces(EvaluationTraceReporter reporter, String description) {
        String returnValue = "";
        if (reporter != null) {
            if (reporter.wereTracesReported()) {
                returnValue += description + "\n";
            }

            StringEvaluationTraceSerializer serializer = new StringEvaluationTraceSerializer();

            for (EvaluationTrace trace : reporter.getCollectedTraces()) {
                returnValue += trace.getExpression() + ": " + trace.getValue()  + "\n";
                returnValue += serializer.serializeEvaluationLevels(trace);
            }

            reporter.reset();
        }
        return returnValue;
    }

}

Add a way to evaluate traces into a single string output


/*
 * Copyright (C) 2009 XStream Committers.
 * All rights reserved.
 *
 * Created on 15. August 2009 by Joerg Schaible
 */
package com.thoughtworks.xstream.io.xml;

/**
 * A XmlFriendlyNameCoder to support backward compatibility with XStream 1.1.
 *
 * @author Jörg Schaible
 * @since upcoming
 */
public class XStream11NameCoder extends XmlFriendlyNameCoder {

    /**
     * {@inheritDoc} Noop implementation that does not decode. Used for XStream 1.1
     * compatibility.
     */
    public String decodeAttribute(String attributeName) {
        return attributeName;
    }

    /**
     * {@inheritDoc} Noop implementation that does not decode. Used for XStream 1.1
     * compatibility.
     */
    public String decodeNode(String elementName) {
        return elementName;
    }
}

/*
 * Copyright (C) 2009 XStream Committers.
 * All rights reserved.
 *
 * The software in this package is published under the terms of the BSD
 * style license a copy of which has been included with this distribution in
 * the LICENSE.txt file.
 *
 * Created on 15. August 2009 by Joerg Schaible
 */
package com.thoughtworks.xstream.io.xml;

/**
 * A XmlFriendlyNameCoder to support backward compatibility with XStream 1.1.
 *
 * @author Jörg Schaible
 * @since upcoming
 */
public class XStream11NameCoder extends XmlFriendlyNameCoder {

    /**
     * {@inheritDoc} Noop implementation that does not decode. Used for XStream 1.1
     * compatibility.
     */
    public String decodeAttribute(String attributeName) {
        return attributeName;
    }

    /**
     * {@inheritDoc} Noop implementation that does not decode. Used for XStream 1.1
     * compatibility.
     */
    public String decodeNode(String elementName) {
        return elementName;
    }
}

Fix file headers for missing BSD license.


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jackrabbit.oak.kernel;

import org.apache.jackrabbit.oak.NodeStoreFixture;
import org.apache.jackrabbit.oak.spi.state.NodeStore;

class AbstractKernelTest {

    protected NodeStore createNodeStore() {
        return NodeStoreFixture.MK_IMPL.createNodeStore();
    }
}

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jackrabbit.oak.kernel;

import org.apache.jackrabbit.oak.NodeStoreFixture;
import org.apache.jackrabbit.oak.spi.state.NodeStore;

class AbstractKernelTest {

    protected NodeStore createNodeStore() {
        return NodeStoreFixture.SEGMENT_MK.createNodeStore();
    }
}

OAK-1847: Use SegmentMK for testing where possible

git-svn-id: 67138be12999c61558c3dd34328380c8e4523e73@1596603 13f79535-47bb-0310-9956-ffa450edef68


package info.u_team.u_team_test.data.provider;

import java.util.function.BiConsumer;

import info.u_team.u_team_core.data.*;
import info.u_team.u_team_test.init.*;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.LootTable;

public class TestLootTablesProvider extends CommonLootTablesProvider {

	public TestLootTablesProvider(GenerationData data) {
		super(data);
	}

	@Override
	protected void registerLootTables(BiConsumer<ResourceLocation, LootTable> consumer) {
		registerBlock(TestBlocks.BASIC, addFortuneBlockLootTable(TestBlocks.BASIC.get(), TestItems.BASIC.get()), consumer);
		registerBlock(TestBlocks.BASIC_TILEENTITY, addTileEntityBlockLootTable(TestBlocks.BASIC_TILEENTITY.get()), consumer);
		registerBlock(TestBlocks.BASIC_ENERGY_CREATOR, addTileEntityBlockLootTable(TestBlocks.BASIC_ENERGY_CREATOR.get()), consumer);
		registerBlock(TestBlocks.BASIC_FLUID_INVENTORY, addTileEntityBlockLootTable(TestBlocks.BASIC_FLUID_INVENTORY.get()), consumer);
	}

}

package info.u_team.u_team_test.data.provider;

import java.util.function.BiConsumer;

import info.u_team.u_team_core.data.*;
import info.u_team.u_team_test.init.*;
import net.minecraft.loot.LootTable;
import net.minecraft.util.ResourceLocation;

public class TestLootTablesProvider extends CommonLootTablesProvider {

	public TestLootTablesProvider(GenerationData data) {
		super(data);
	}

	@Override
	protected void registerLootTables(BiConsumer<ResourceLocation, LootTable> consumer) {
		registerBlock(TestBlocks.BASIC, addFortuneBlockLootTable(TestBlocks.BASIC.get(), TestItems.BASIC.get()), consumer);
		registerBlock(TestBlocks.BASIC_TILEENTITY, addTileEntityBlockLootTable(TestBlocks.BASIC_TILEENTITY.get()), consumer);
		registerBlock(TestBlocks.BASIC_ENERGY_CREATOR, addTileEntityBlockLootTable(TestBlocks.BASIC_ENERGY_CREATOR.get()), consumer);
		registerBlock(TestBlocks.BASIC_FLUID_INVENTORY, addTileEntityBlockLootTable(TestBlocks.BASIC_FLUID_INVENTORY.get()), consumer);
	}

}

Fix import in test loot tables provider

Fix import in test loot tables provider


package com.worldofbuzz.autoconfigure.spring.web.formatting.fieldannotation.barcode;

import com.worldofbuzz.autoconfigure.spring.web.validator.BarcodeValidator;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = BarcodeValidator.class)
@NotEmpty
public @interface Barcode {

    String message() default "Invalid barcode.";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}

package com.worldofbuzz.autoconfigure.spring.web.formatting.fieldannotation.barcode;

import com.worldofbuzz.autoconfigure.spring.web.validator.BarcodeValidator;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = BarcodeValidator.class)
@NotEmpty
public @interface Barcode {

    String message() default "Sorry, the barcode you've entered hasn't been recognised. Please try again.";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}

Update barcode validation error message.


package net.darkhax.bookshelf.mixin.item;

import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(Item.class)
public interface AccessorItem {

    @Mutable
    @Accessor("category")
    void bookshelf$setCreativeTab(CreativeModeTab tab);
}

package net.darkhax.bookshelf.mixin.item;

import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(Item.class)
public interface AccessorItem {

    @Mutable
    @Accessor("category")
    void bookshelf$setCreativeTab(CreativeModeTab tab);

    @Mutable
    @Accessor("craftingRemainingItem")
    void bookshelf$setCraftingRemainder(Item item);
}

Allow mods to change the remainder crafting item after the item has been initialized.


package com.codeaffine.extras.workingset.internal;

import static org.junit.Assert.assertNotNull;

import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.List;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.junit.Test;

import com.codeaffine.extras.workingset.internal.Images;

public class ImagesPDETest {

  @Test
  public void testRegisteredImages() throws IllegalAccessException {
    for( String constantValue : getConstantValues() ) {
      checkImageDescriptor( constantValue );
    }
  }

  private static void checkImageDescriptor( String constantValue ) {
    ImageDescriptor descriptor = Images.getImageDescriptor( constantValue );
    assertNotNull( "No image descriptor registered for: " + constantValue, descriptor );
    Image image = descriptor.createImage( false );
    assertNotNull( "Image descriptor does not return image: " + constantValue, image );
    image.dispose();
  }

  private static String[] getConstantValues() throws IllegalAccessException {
    List<String> constantValues = new LinkedList<>();
    Field[] declaredFields = Images.class.getDeclaredFields();
    for( Field constant : declaredFields ) {
      constantValues.add( ( String )constant.get( null ) );
    }
    return constantValues.toArray( new String[ constantValues.size() ] );
  }
}

package com.codeaffine.extras.workingset.internal;

import static java.lang.reflect.Modifier.isPublic;
import static java.lang.reflect.Modifier.isStatic;
import static org.junit.Assert.assertNotNull;

import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.List;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.junit.Test;

public class ImagesPDETest {

  @Test
  public void testRegisteredImages() throws IllegalAccessException {
    for( String constantValue : getConstantValues() ) {
      checkImageDescriptor( constantValue );
    }
  }

  private static void checkImageDescriptor( String constantValue ) {
    ImageDescriptor descriptor = Images.getImageDescriptor( constantValue );
    assertNotNull( "No image descriptor registered for: " + constantValue, descriptor );
    Image image = descriptor.createImage( false );
    assertNotNull( "Image descriptor does not return image: " + constantValue, image );
    image.dispose();
  }

  private static String[] getConstantValues() throws IllegalAccessException {
    List<String> constantValues = new LinkedList<>();
    Field[] declaredFields = Images.class.getDeclaredFields();
    for( Field declaredField : declaredFields ) {
      if( isStatic( declaredField.getModifiers() ) && isPublic( declaredField.getModifiers() ) ) {
        constantValues.add( ( String )declaredField.get( null ) );
      }
    }
    return constantValues.toArray( new String[ constantValues.size() ] );
  }
}

Work around occasionally thrown IllegalAccessException


package com.github.googlei18n.tachyfont;

import java.io.IOException;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import javax.servlet.http.*;

@SuppressWarnings("serial")
public class TachyFontServlet extends HttpServlet {
  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/plain");
    String jarFilename = "fonts/noto/sans/NotoSansJP-Thin_subset_smp.TachyFont.jar";
    JarFile jarFile = new JarFile("WEB-INF/" + jarFilename);
    resp.getWriter().println("Jar entries in " + jarFilename + ":");
    Enumeration<JarEntry> enumEntries = jarFile.entries();
    resp.getWriter().println("jar file:");
    while (enumEntries.hasMoreElements()) {
      JarEntry jarEntry = enumEntries.nextElement();
      resp.getWriter().println("  " + jarEntry.getName());
    }

    JarEntry base = jarFile.getJarEntry("base");
    JarEntry closure_data = jarFile.getJarEntry("closure_data");
    JarEntry closure_idx = jarFile.getJarEntry("closure_idx");
    JarEntry codepoints = jarFile.getJarEntry("codepoints");
    JarEntry gids = jarFile.getJarEntry("gids");
    JarEntry glyph_data = jarFile.getJarEntry("glyph_data");
    JarEntry glyph_table = jarFile.getJarEntry("glyph_table");
    jarFile.close();
  }
}

package com.github.googlei18n.tachyfont;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import javax.servlet.http.*;

@SuppressWarnings("serial")
public class TachyFontServlet extends HttpServlet {
  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/plain");
    String jarFilename = "fonts/noto/sans/NotoSansJP-Thin_subset_smp.TachyFont.jar";
    JarFile jarFile = new JarFile("WEB-INF/" + jarFilename);
    resp.getWriter().println("Jar file: " + jarFilename);
    Enumeration<JarEntry> enumEntries = jarFile.entries();
    resp.getWriter().println("jar file entries:");
    while (enumEntries.hasMoreElements()) {
      JarEntry jarEntry = enumEntries.nextElement();
      resp.getWriter().println("  " + jarEntry.getName());
    }

    JarEntry base = jarFile.getJarEntry("base");
    InputStream baseStream = jarFile.getInputStream(base);
    JarEntry closure_data = jarFile.getJarEntry("closure_data");
    JarEntry closure_idx = jarFile.getJarEntry("closure_idx");
    JarEntry codepoints = jarFile.getJarEntry("codepoints");
    JarEntry gids = jarFile.getJarEntry("gids");
    JarEntry glyph_data = jarFile.getJarEntry("glyph_data");
    JarEntry glyph_table = jarFile.getJarEntry("glyph_table");
    jarFile.close();
  }
}

Access the base file in the JAR.

Access the base file in the JAR.


package com.redhat.ceylon.eclipse.core.typechecker;

import java.util.List;

import org.antlr.runtime.CommonToken;

import com.redhat.ceylon.compiler.typechecker.TypeChecker;
import com.redhat.ceylon.compiler.typechecker.analyzer.ModuleManager;
import com.redhat.ceylon.compiler.typechecker.context.PhasedUnit;
import com.redhat.ceylon.compiler.typechecker.io.VirtualFile;
import com.redhat.ceylon.compiler.typechecker.model.Package;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.CompilationUnit;

public class IdePhasedUnit extends PhasedUnit {

    private TypeChecker typeChecker;

    public IdePhasedUnit(VirtualFile unitFile, VirtualFile srcDir,
            CompilationUnit cu, Package p, ModuleManager moduleManager,
            TypeChecker typeChecker, List<CommonToken> tokenStream) {
        super(unitFile, srcDir, cu, p, moduleManager, typeChecker.getContext(), tokenStream);
        this.typeChecker = typeChecker;
    }

    public IdePhasedUnit(PhasedUnit other) {
        super(other);
        if (other instanceof IdePhasedUnit) {
            typeChecker = ((IdePhasedUnit) other).typeChecker;
        }
    }

    public TypeChecker getTypeChecker() {
        return typeChecker;
    }
}

package com.redhat.ceylon.eclipse.core.typechecker;

import java.util.List;

import org.antlr.runtime.CommonToken;

import com.redhat.ceylon.compiler.typechecker.TypeChecker;
import com.redhat.ceylon.compiler.typechecker.analyzer.ModuleManager;
import com.redhat.ceylon.compiler.typechecker.context.PhasedUnit;
import com.redhat.ceylon.compiler.typechecker.io.VirtualFile;
import com.redhat.ceylon.compiler.typechecker.model.Package;
import com.redhat.ceylon.compiler.typechecker.model.Unit;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.CompilationUnit;

public abstract class IdePhasedUnit extends PhasedUnit {

    private TypeChecker typeChecker;

    public IdePhasedUnit(VirtualFile unitFile, VirtualFile srcDir,
            CompilationUnit cu, Package p, ModuleManager moduleManager,
            TypeChecker typeChecker, List<CommonToken> tokenStream) {
        super(unitFile, srcDir, cu, p, moduleManager, typeChecker.getContext(), tokenStream);
        this.typeChecker = typeChecker;
    }

    public IdePhasedUnit(PhasedUnit other) {
        super(other);
        if (other instanceof IdePhasedUnit) {
            typeChecker = ((IdePhasedUnit) other).typeChecker;
        }
    }

    public TypeChecker getTypeChecker() {
        return typeChecker;
    }

    public abstract Unit createUnit();
}

Make it abstract and redefine createUnit() as abstract


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.gshell.testsuite;

import org.apache.gshell.registry.CommandRegistrar;
import org.apache.maven.shell.ShellBuilder;

/**
 * Builds {@link org.apache.gshell.Shell} instances.
 *
 * @author Jason Dillon
 */
public class TestShellBuilder
    extends ShellBuilder
{
    protected void registerCommand(final String name, final String type) throws Exception {
        CommandRegistrar registrar = getContainer().lookup(CommandRegistrar.class);
        registrar.registerCommand(name, type);
    }
}

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.gshell.testsuite;

import org.apache.gshell.registry.CommandRegistrar;
import org.apache.gshell.Shell;
import org.apache.maven.shell.ShellBuilder;

/**
 * Builds {@link org.apache.gshell.Shell} instances.
 *
 * @author Jason Dillon
 */
public class TestShellBuilder
    extends ShellBuilder
{
    protected void registerCommand(final String name, final String type) throws Exception {
        CommandRegistrar registrar = getContainer().lookup(CommandRegistrar.class);
        registrar.registerCommand(name, type);
    }

    @Override
    public Shell create() throws Exception {
        setRegisterCommands(false);
        return super.create();
    }
}

Speed up tests, only register what is required


package dk.statsbiblioteket.doms.transformers.common;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/** Configuration based on property file. */
public class PropertyBasedConfig implements Config {

    /** Property specifying the directory where output files will be stored. */
    public static final String OUTPUT_DIRECTORY_PROPERTY
            = "dk.statsbiblioteket.doms.transformers.outputdirectory";

    /** Properties containing configuration. */
    protected final Properties properties;

    /** Initialise based on system properties. */
    public PropertyBasedConfig() {
        properties = new Properties(System.getProperties());
    }

    /**
     * Read configuration from property file. Backed by system properties.
     *
     * @param configfile File with properties.
     * @throws IOException If file can not be read.
     */
    public PropertyBasedConfig(File configfile) throws IOException {
        this();
        properties.load(new FileInputStream(configfile));
    }

    public String getProperty(String property) {
        return properties.getProperty(property);
    }

    public String getProperty(String property, String defaultValue) {
        return properties.getProperty(property, defaultValue);
    }

    @Override
    public String getOutputDirectory() {
        return properties.getProperty(OUTPUT_DIRECTORY_PROPERTY, "output");
    }
}

package dk.statsbiblioteket.doms.transformers.common;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/** Configuration based on property file. */
public class PropertyBasedConfig implements Config {

    /** Property specifying the directory where output files will be stored. */
    public static final String OUTPUT_DIRECTORY_PROPERTY
            = "dk.statsbiblioteket.doms.transformers.outputdirectory";

    /** Properties containing configuration. */
    protected final Properties properties;

    /** Initialise based on system properties. */
    public PropertyBasedConfig() {
        properties = new Properties(System.getProperties());
    }

    /**
     * Read configuration from property file. Backed by system properties.
     *
     * @param configfile File with properties.
     * @throws IOException If file can not be read.
     */
    public PropertyBasedConfig(File configfile) throws IOException {
        this();
        properties.load(new FileInputStream(configfile));
    }

    @Override
    public String getOutputDirectory() {
        return properties.getProperty(OUTPUT_DIRECTORY_PROPERTY, "output");
    }
}

Revert "Persuade PropertyBaseConfig to output arbitrary properties."

This reverts commit 0fb34a5f82c5554ac714c245241f47670b1f717d.


package uk.ac.ebi.quickgo.annotation.download.converter.helpers;

import uk.ac.ebi.quickgo.annotation.model.Annotation;

import java.util.List;
import java.util.stream.Collectors;

/**
 * A home for the logic to format ConnectedXRefs into Strings.
 *
 * @author Tony Wardell
 * Date: 09/04/2018
 * Time: 13:06
 * Created with IntelliJ IDEA.
 */
public class ConnectedXRefs {
    private static final String PIPE = "|";
    private static final String COMMA = ",";

    private ConnectedXRefs() {}

    public static String asString(List<Annotation.ConnectedXRefs<Annotation.SimpleXRef>> connectedXRefs) {
        if (connectedXRefs == null || connectedXRefs.isEmpty()) {
            return "";
        }
        return connectedXRefs.stream()
                .map(ConnectedXRefs::simpleRefAndToString)
                .collect(Collectors.joining(PIPE));
    }

    private static String simpleRefAndToString(Annotation.ConnectedXRefs<Annotation.SimpleXRef> itemList) {
        return itemList.getConnectedXrefs()
                .stream()
                .map(Annotation.SimpleXRef::asXref)
                .collect(Collectors.joining(COMMA));
    }

}

package uk.ac.ebi.quickgo.annotation.download.converter.helpers;

import uk.ac.ebi.quickgo.annotation.model.Annotation;

import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * A home for the logic to format ConnectedXRefs into Strings.
 *
 * @author Tony Wardell
 * Date: 09/04/2018
 * Time: 13:06
 * Created with IntelliJ IDEA.
 */
public class ConnectedXRefs {
    private static final String PIPE = "|";
    private static final String COMMA = ",";

    private ConnectedXRefs() {}

    public static String asString(List<Annotation.ConnectedXRefs<Annotation.SimpleXRef>> connectedXRefs) {
        Objects.requireNonNull(connectedXRefs);
        return connectedXRefs.stream()
                .map(ConnectedXRefs::simpleRefAndToString)
                .collect(Collectors.joining(PIPE));
    }

    private static String simpleRefAndToString(Annotation.ConnectedXRefs<Annotation.SimpleXRef> itemList) {
        return itemList.getConnectedXrefs()
                .stream()
                .map(Annotation.SimpleXRef::asXref)
                .collect(Collectors.joining(COMMA));
    }

}

Change null check to throw NPE.

Change null check to throw NPE.


/*
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

package org.opendaylight.controller.concepts.transform;

public interface Acceptor<I> {

    /**
     *
     * @param input
     * @return true if input is accepted.
     */
    boolean isAcceptable(I input);
}

/*
 * Copyright (c) 2013, 2015 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

package org.opendaylight.controller.concepts.transform;

public interface Acceptor<I> {

    /**
     *
     * @param input
     * @return true if input is accepted.
     */
    boolean isAcceptable(I input);
}

Fix license header violations in concepts

Change-Id: Ia575c2e64b4ce50990e0fadada34f257189c3370
Signed-off-by: Thanh Ha <09ea4d3a79c8bee41a16519f6a431f6bc0fd8d6f@linuxfoundation.org>


/*
 * Copyright (C) 2004 Jive Software. 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.jivesoftware.database;

/**
 * Simple class for tracking profiling stats for individual SQL queries.
 *
 * @author Jive Software
 */
public class ProfiledConnectionEntry {
    /**
     * The SQL query.
     */
    public String sql;

    /**
     * Number of times the query has been executed.
     */
    public int count;

    /**
     * The total time spent executing the query (in milliseconds).
     */
    public int totalTime;

    public ProfiledConnectionEntry(String sql) {
        this.sql = sql;
        count = 0;
        totalTime = 0;
    }
}

/*
 * Copyright (C) 2004 Jive Software. 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.jivesoftware.database;

/**
 * Simple class for tracking profiling stats for individual SQL queries.
 *
 * @author Jive Software
 */
public class ProfiledConnectionEntry {
    /**
     * The SQL query.
     */
    public String sql;

    /**
     * Number of times the query has been executed.
     */
    public int count;

    /**
     * The total time spent executing the query (in milliseconds).
     */
    public long totalTime;

    public ProfiledConnectionEntry(String sql) {
        this.sql = sql;
        count = 0;
        totalTime = 0;
    }
}

OF-2148: Change to wider type to prevent information loss

Prevent a possible issue where a wider type gets added to narrower type.

Ideally, this is replaced by proper types (eg: Duration, Instant), but the cost/benefit of applying that larger change does not pay off.


package org.opennms.netmgt.dao.support;

import java.io.IOException;

import org.opennms.netmgt.dao.ResourceDao;
import org.opennms.netmgt.dao.support.DefaultResourceDao;
import org.opennms.netmgt.dao.support.ResponseTimeResourceType;

import junit.framework.TestCase;

public class ResponseTimeResourceTypeTest extends TestCase {
    public void testGetResourcesUsingDao() throws IOException {
        ResourceDao resourceDao = new DefaultResourceDao();

        ResponseTimeResourceType r = new ResponseTimeResourceType(resourceDao, null);

        r.getResourcesForNode(1);
    }
}

package org.opennms.netmgt.dao.support;

import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import java.io.IOException;

import org.opennms.netmgt.dao.NodeDao;
import org.opennms.netmgt.dao.ResourceDao;
import org.opennms.netmgt.dao.support.DefaultResourceDao;
import org.opennms.netmgt.dao.support.ResponseTimeResourceType;
import org.opennms.netmgt.model.OnmsNode;

import junit.framework.TestCase;

public class ResponseTimeResourceTypeTest extends TestCase {
    public void testGetResourcesUsingDao() throws IOException {
        ResourceDao resourceDao = new DefaultResourceDao();
        NodeDao nodeDao = createMock(NodeDao.class);

        expect(nodeDao.get(1)).andReturn(new OnmsNode());

        ResponseTimeResourceType r = new ResponseTimeResourceType(resourceDao, nodeDao);

        replay(nodeDao);
        r.getResourcesForNode(1);
        verify(nodeDao);
    }
}

Fix failing test by mocking up NodeDao

Fix failing test by mocking up NodeDao


/*
 * Copyright 2020 Crown Copyright
 *
 * 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 stroom.event.logging.rs.impl;

import stroom.rs.logging.impl.RequestInfo;

import javax.annotation.Nullable;

public class MockRequestEventLog implements RequestEventLog {
    @Override
    public void log(final RequestInfo info, @Nullable final Object responseEntity) {

    }

    @Override
    public void log(final RequestInfo info, @Nullable final Object responseEntity, final Throwable error) {

    }
}

/*
 * Copyright 2020 Crown Copyright
 *
 * 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 stroom.event.logging.rs.impl;

import javax.annotation.Nullable;

public class MockRequestEventLog implements RequestEventLog {
    @Override
    public void log(final RequestInfo info, @Nullable final Object responseEntity) {

    }

    @Override
    public void log(final RequestInfo info, @Nullable final Object responseEntity, final Throwable error) {

    }
}

Fix problem introduced during recent refactor


package com.infinityraider.agricraft.api.v1.client;

import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

/**
 * Enum representing the different types AgriCraft plants / weeds are rendered
 */
@OnlyIn(Dist.CLIENT)
public enum AgriPlantRenderType {
    /** Renders in a hashtag pattern (#); 4 faces parallel with the block faces, similar to Vanilla wheat */
    HASH,

    /** Renders in a cross pattern (x); 2 faces along the diagonals, similar to Vanilla flowers */
    CROSS,

    /** Renders in a plus pattern (+); similar to cross, but instead 4 crosses at each crop stick */
    PLUS,

    /** Renders in a rhombus pattern (◇); 4 faces spanning between the centers of the block faces, only used for weeds */
    RHOMBUS
}

package com.infinityraider.agricraft.api.v1.client;

import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.IExtensibleEnum;

/**
 * Enum representing the different types AgriCraft plants / weeds are rendered
 */
@OnlyIn(Dist.CLIENT)
public enum AgriPlantRenderType implements IExtensibleEnum {
    /** Renders in a hashtag pattern (#); 4 faces parallel with the block faces, similar to Vanilla wheat */
    HASH,

    /** Renders in a cross pattern (x); 2 faces along the diagonals, similar to Vanilla flowers */
    CROSS,

    /** Renders in a plus pattern (+); similar to cross, but instead 4 crosses at each crop stick */
    PLUS,

    /** Renders in a rhombus pattern (◇); 4 faces spanning between the centers of the block faces, only used for weeds */
    RHOMBUS;

    @SuppressWarnings("unused")
    public static AgriPlantRenderType create(String name) {
        throw new IllegalStateException("Enum not extended");
    }
}

Make Render Type enum extensible

Make Render Type enum extensible


package org.dynamicfinder.jpa.handler;

/**
 * @author xsalefter (xsalefter[at]gmail.com)
 */
public class LikeWithPostfixRestrictionHandler extends LikeComparatorRestrictionHandler {

	private static final String PREFIX = "'%',";
	private static final String POSTFIX = "";

	public LikeWithPostfixRestrictionHandler() {
		super(PREFIX, POSTFIX);
	}

}

package org.dynamicfinder.jpa.handler;

/**
 * @author xsalefter (xsalefter[at]gmail.com)
 */
public class LikeWithPostfixRestrictionHandler extends LikeComparatorRestrictionHandler {

	private static final String PREFIX = "'%', ";
	private static final String POSTFIX = "";

	public LikeWithPostfixRestrictionHandler() {
		super(PREFIX, POSTFIX);
	}

}

Fix generated string format. (cosmetic)

Fix generated string format. (cosmetic)


/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * 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.facebook.litho.editor.instances;

import com.facebook.litho.editor.Editor;
import com.facebook.litho.editor.model.EditorBool;
import com.facebook.litho.editor.model.EditorValue;
import java.lang.reflect.Field;

public class BoolEditorInstance implements Editor {

  @Override
  public EditorValue read(Field f, Object node) {
    return EditorValue.bool(EditorUtils.<Boolean>getNodeUNSAFE(f, node));
  }

  @Override
  public boolean write(final Field f, final Object node, final EditorValue values) {
    values.when(
        new EditorValue.DefaultEditorVisitor() {
          @Override
          public Void isBool(EditorBool bool) {
            EditorUtils.setNodeUNSAFE(f, node, bool.value);
            return null;
          }
        });
    return true;
  }
}

/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * 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.facebook.litho.editor.instances;

import com.facebook.litho.editor.Editor;
import com.facebook.litho.editor.model.EditorBool;
import com.facebook.litho.editor.model.EditorValue;
import java.lang.reflect.Field;

public class BoolEditorInstance implements Editor {

  @Override
  public EditorValue read(final Field f, final Object node) {
    // If you use Boolean here it causes an exception when attempting to do implicit conversion to
    // boolean
    final Object b = EditorUtils.<Object>getNodeUNSAFE(f, node);
    return b == null ? EditorValue.string("null") : EditorValue.bool((Boolean) b);
  }

  @Override
  public boolean write(final Field f, final Object node, final EditorValue values) {
    values.when(
        new EditorValue.DefaultEditorVisitor() {
          @Override
          public Void isBool(final EditorBool bool) {
            EditorUtils.setNodeUNSAFE(f, node, bool.value);
            return null;
          }
        });
    return true;
  }
}

Add support for nullable Booleans

Add support for nullable Booleans

Summary:
Before this diff, a null Boolean prop would cause an exception, as reported by priteshrnandgaonkar

{F338566882}

Reviewed By: priteshrnandgaonkar

Differential Revision: D24111821

fbshipit-source-id: ae33aa9d70d3878d62ce4a1be89505e7e9319784


package com.reactnativenavigation.params.parsers;

import android.os.Bundle;

import com.reactnativenavigation.params.ActivityParams;
import com.reactnativenavigation.params.AppStyle;
import com.reactnativenavigation.params.SideMenuParams;
import com.reactnativenavigation.views.SideMenu;

public class ActivityParamsParser extends Parser {
    public static ActivityParams parse(Bundle params) {
        ActivityParams result = new ActivityParams();

        AppStyle.setAppStyle(params);

        if (hasKey(params, "screen")) {
            result.type = ActivityParams.Type.SingleScreen;
            result.screenParams = ScreenParamsParser.parse(params.getBundle("screen"));
        }

        if (hasKey(params, "tabs")) {
            result.type = ActivityParams.Type.TabBased;
            result.tabParams = new ScreenParamsParser().parseTabs(params.getBundle("tabs"));
        }

        if (hasKey(params, "sideMenu")) {
            SideMenuParams[] sideMenus = SideMenuParamsParser.parse(params.getBundle("sideMenu"));
            result.leftSideMenuParams = sideMenus[SideMenu.Side.Left.ordinal()];
            result.rightSideMenuParams = sideMenus[SideMenu.Side.Right.ordinal()];
        }

        result.animateShow = params.getBoolean("animateShow", true);

        return result;
    }
}

package com.reactnativenavigation.params.parsers;

import android.os.Bundle;

import com.reactnativenavigation.params.ActivityParams;
import com.reactnativenavigation.params.AppStyle;
import com.reactnativenavigation.params.SideMenuParams;
import com.reactnativenavigation.views.SideMenu;

public class ActivityParamsParser extends Parser {
    public static ActivityParams parse(Bundle params) {
        ActivityParams result = new ActivityParams();

        AppStyle.setAppStyle(params);

        if (hasKey(params, "screen")) {
            result.type = ActivityParams.Type.SingleScreen;
            result.screenParams = ScreenParamsParser.parse(params.getBundle("screen"));
        }

        if (hasKey(params, "tabs")) {
            result.type = ActivityParams.Type.TabBased;
            result.tabParams = new ScreenParamsParser().parseTabs(params.getBundle("tabs"));
            if (result.tabParams.size() == 0) {
                throw new RuntimeException("Tried to start tab based app with zero tabs");
            }
        }

        if (hasKey(params, "sideMenu")) {
            SideMenuParams[] sideMenus = SideMenuParamsParser.parse(params.getBundle("sideMenu"));
            result.leftSideMenuParams = sideMenus[SideMenu.Side.Left.ordinal()];
            result.rightSideMenuParams = sideMenus[SideMenu.Side.Right.ordinal()];
        }

        result.animateShow = params.getBoolean("animateShow", true);

        return result;
    }
}

Throw exception when calling startTabBasedApp with zero tabs


package com.infinityraider.infinitylib.item;

import com.infinityraider.infinitylib.render.item.IItemRenderingHandler;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public interface ICustomRenderedItem<I extends Item> {
    /**
     * Gets called to create the IBlockRenderingHandler instance to render this block with
     * @return a new IItemRenderingHandler object for this block
     */
    @SideOnly(Side.CLIENT)
    IItemRenderingHandler<I> getRenderer();

    /**
     * Gets an array of ResourceLocations used for the model of this block, all block states for this block will use this as key in the model registry
     * @return a unique ModelResourceLocation for this block
     */
    @SideOnly(Side.CLIENT)
    ModelResourceLocation getItemModelResourceLocation();
}

package com.infinityraider.infinitylib.item;

import com.infinityraider.infinitylib.render.item.IItemRenderingHandler;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.List;

public interface ICustomRenderedItem<I extends Item> {
    /**
     * Gets called to create the IBlockRenderingHandler instance to render this block with
     * @return a new IItemRenderingHandler object for this block
     */
    @SideOnly(Side.CLIENT)
    IItemRenderingHandler<I> getRenderer();

    /**
     * Gets a list of all textures necessary to render this item,
     * returned textures will be stitched to the atlas
     * @return list of textures
     */
    @SideOnly(Side.CLIENT)
    List<ResourceLocation> getTextures();

    /**
     * Gets an array of ResourceLocations used for the model of this block, all block states for this block will use this as key in the model registry
     * @return a unique ModelResourceLocation for this block
     */
    @SideOnly(Side.CLIENT)
    ModelResourceLocation getItemModelResourceLocation();
}

Add get textures method for items

Add get textures method for items


package com.hubspot.jinjava.util;

import com.hubspot.jinjava.interpret.OutputTooBigException;
import java.io.Serializable;
import java.util.stream.IntStream;

public class LengthLimitingStringBuilder implements Serializable, CharSequence {
  private static final long serialVersionUID = -1891922886257965755L;

  private final StringBuilder builder;
  private long length = 0;
  private final long maxLength;

  public LengthLimitingStringBuilder(long maxLength) {
    builder = new StringBuilder();
    this.maxLength = maxLength;
  }

  @Override
  public int length() {
    return builder.length();
  }

  @Override
  public char charAt(int index) {
    return builder.charAt(index);
  }

  @Override
  public CharSequence subSequence(int start, int end) {
    return builder.subSequence(start, end);
  }

  @Override
  public String toString() {
    return builder.toString();
  }

  @Override
  public IntStream chars() {
    return builder.chars();
  }

  @Override
  public IntStream codePoints() {
    return builder.codePoints();
  }

  public void append(Object obj) {
    append(String.valueOf(obj));
  }

  public void append(String str) {
    length += str.length();
    if (maxLength > 0 && length > maxLength) {
      throw new OutputTooBigException(maxLength, length);
    }
    builder.append(str);
  }
}

package com.hubspot.jinjava.util;

import com.hubspot.jinjava.interpret.OutputTooBigException;
import java.io.Serializable;
import java.util.stream.IntStream;

public class LengthLimitingStringBuilder implements Serializable, CharSequence {
  private static final long serialVersionUID = -1891922886257965755L;

  private final StringBuilder builder;
  private long length = 0;
  private final long maxLength;

  public LengthLimitingStringBuilder(long maxLength) {
    builder = new StringBuilder();
    this.maxLength = maxLength;
  }

  @Override
  public int length() {
    return builder.length();
  }

  @Override
  public char charAt(int index) {
    return builder.charAt(index);
  }

  @Override
  public CharSequence subSequence(int start, int end) {
    return builder.subSequence(start, end);
  }

  @Override
  public String toString() {
    return builder.toString();
  }

  @Override
  public IntStream chars() {
    return builder.chars();
  }

  @Override
  public IntStream codePoints() {
    return builder.codePoints();
  }

  public void append(Object obj) {
    append(String.valueOf(obj));
  }

  public void append(String str) {
    if (str == null) {
      return;
    }
    length += str.length();
    if (maxLength > 0 && length > maxLength) {
      throw new OutputTooBigException(maxLength, length);
    }
    builder.append(str);
  }
}

Check for null value before appending

Check for null value before appending


package ua.uagames.borsch.v002;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

package ua.uagames.borsch.v002;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.firebase.analytics.FirebaseAnalytics;

public class MainActivity extends AppCompatActivity {
    private WebView viewer;
    private FirebaseAnalytics analytics;
    private Bundle bundle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        analytics = FirebaseAnalytics.getInstance(this);
        bundle = new Bundle();

        viewer = (WebView) findViewById(R.id.viewer);
        viewer.getSettings().setJavaScriptEnabled(true);
        viewer.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                return false;
            }
        });

        viewer.loadUrl("https://drive.google.com/file/d/0B3qWNFQol8lILVlzQlJ3V3VHTTg/view?usp=sharing");

        bundle.putString("app_name", "Borsch v002.");
        bundle.putString("app_event", "Create app and load content.");
        analytics.logEvent("app_statistics", bundle);
    }
}

Change project Borschv002. Add app functional with firebase statistics.


/* 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.flowable.engine.test.bpmn.event.variable;

import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.common.engine.impl.el.ExpressionManager;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.impl.util.CommandContextUtil;

public class SetVariableExpression {

    public void setVariable(String variable, Object value, DelegateExecution execution) {
        ExpressionManager expressionManager = CommandContextUtil.getProcessEngineConfiguration().getExpressionManager();
        Expression expression = expressionManager.createExpression("${" + variable + "}");
        expression.setValue(value, execution);
    }
}

Add missing license header block

Chore: Add missing license header block


/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

package com.facebook.react.uiapp;

import androidx.annotation.VisibleForTesting;
import com.facebook.jni.HybridData;
import com.facebook.react.ReactPackage;
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.soloader.SoLoader;
import java.util.List;

/** This class is responsible for creating all the TurboModules for the RNTester app. */
public class RNTesterTurboModuleManagerDelegate extends ReactPackageTurboModuleManagerDelegate {
  private static volatile boolean sIsSoLibraryLoaded;

  protected native HybridData initHybrid();

  @VisibleForTesting
  native boolean canCreateTurboModule(String moduleName);

  private RNTesterTurboModuleManagerDelegate(
      ReactApplicationContext context, List<ReactPackage> packages) {
    super(context, packages);
  }

  public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
    protected RNTesterTurboModuleManagerDelegate build(
        ReactApplicationContext context, List<ReactPackage> packages) {
      return new RNTesterTurboModuleManagerDelegate(context, packages);
    }
  }

  @Override
  protected void maybeLoadOtherSoLibraries() {
    maybeLoadSoLibraries();
  }

  // Prevents issues with initializer interruptions.
  private static synchronized void maybeLoadSoLibraries() {
    if (!sIsSoLibraryLoaded) {
      SoLoader.loadLibrary("rntester_appmodules");
      sIsSoLibraryLoaded = true;
    }
  }
}

/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

package com.facebook.react.uiapp;

import androidx.annotation.VisibleForTesting;
import com.facebook.jni.HybridData;
import com.facebook.react.ReactPackage;
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.soloader.SoLoader;
import java.util.List;

/** This class is responsible for creating all the TurboModules for the RNTester app. */
public class RNTesterTurboModuleManagerDelegate extends ReactPackageTurboModuleManagerDelegate {
  private static volatile boolean sIsSoLibraryLoaded;

  protected native HybridData initHybrid();

  @VisibleForTesting
  native boolean canCreateTurboModule(String moduleName);

  private RNTesterTurboModuleManagerDelegate(
      ReactApplicationContext context, List<ReactPackage> packages) {
    super(context, packages);
  }

  public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
    protected RNTesterTurboModuleManagerDelegate build(
        ReactApplicationContext context, List<ReactPackage> packages) {
      return new RNTesterTurboModuleManagerDelegate(context, packages);
    }
  }

  @Override
  protected synchronized void maybeLoadOtherSoLibraries() {
    // Prevents issues with initializer interruptions.
    if (!sIsSoLibraryLoaded) {
      SoLoader.loadLibrary("rntester_appmodules");
      sIsSoLibraryLoaded = true;
    }
  }
}

Make So loading inside generated TMM delegates less confusing

Summary:
## Rationale
Inlining the maybeLoadSoLibrary private static method makes following the So load chain from TurboModuleManagerDelegate through ReactPackageTurboModuleManagerDelegate to each app's TurboModuleManagerDelegate much easier to understand.

Changelog: [Internal]

Reviewed By: sshic

Differential Revision: D30082675

fbshipit-source-id: ff467d6ac8c792317dd9bdcd91844d3b480cbb60


package com.redhat.che.keycloak.server;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class KeycloakAuthenticationFilter extends org.keycloak.adapters.servlet.KeycloakOIDCFilter {

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        String auth = request.getHeader("Authorization");
        if(auth == null ){
            System.out.println("No auth header for " + request.getRequestURI());
        }
        if(auth != null && auth.equals("Internal")){
            chain.doFilter(req, res);
        }else
        if (request.getRequestURI().endsWith("/ws") || request.getRequestURI().endsWith("/eventbus")
                || request.getScheme().equals("ws") || req.getScheme().equals("wss")) {
            System.out.println("Skipping " + request.getRequestURI());
            chain.doFilter(req, res);
        } else {
            super.doFilter(req, res, chain);
            System.out.println(request.getRequestURL() + " status : " + ((HttpServletResponse) res).getStatus());
        }
    }

}

package com.redhat.che.keycloak.server;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class KeycloakAuthenticationFilter extends org.keycloak.adapters.servlet.KeycloakOIDCFilter {

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        String auth = request.getHeader("Authorization");
        if(auth == null ){
            System.out.println("No auth header for " + request.getRequestURI());
        }
        if(auth != null && auth.equals("Internal")){
            chain.doFilter(req, res);
        } else if (request.getRequestURI().endsWith("/ws") || request.getRequestURI().endsWith("/eventbus")
                   || request.getScheme().equals("ws") || req.getScheme().equals("wss") || request.getRequestURI().contains("/websocket/")) {
            System.out.println("Skipping " + request.getRequestURI());
            chain.doFilter(req, res);
        } else {
            super.doFilter(req, res, chain);
            System.out.println(request.getRequestURL() + " status : " + ((HttpServletResponse) res).getStatus());
        }
    }

}

Fix keycloak auth filter not excluded all websocket request

Signed-off-by: Sun Seng David Tan <a9f1581903e4bd3aaa1590f4fc9da1fa6887498b@redhat.com>


package edu.berkeley.eecs.cfc_tracker.test.location;

import android.content.Intent;
import android.util.Log;

/**
 * Created by shankari on 1/18/15.
 */
public class MockLocationBroadcastChecker extends BroadcastChecker {
    private static final String TAG = "MockLocationBroadcastChecker";
    private int code1;
    private int code2;

    public MockLocationBroadcastChecker(String broadcastAction, int code1, int code2) {
        super(broadcastAction);
        this.code1 = code1;
        this.code2 = code2;
        Log.d(TAG, "Creation done with "+broadcastAction+", "+code1+", "+code2);
    }

    public boolean isMatchingIntent(Intent intent) {
        if (super.isMatchingIntent(intent)) {
            int iCode1 = intent.getIntExtra(LocationUtils.KEY_EXTRA_CODE1, 0);
            int iCode2 = intent.getIntExtra(LocationUtils.KEY_EXTRA_CODE2, 0);
            Log.d(TAG, "intent string matches, checking extra codes from intent "+
                iCode1+", "+iCode2+" against stored "+code1+", "+code2);

            if (iCode1 == code1 &&
                    iCode2 == code2) {
                return true;
            }
        }
        return false;
    }
}

package edu.berkeley.eecs.cfc_tracker.test.location;

import android.content.Intent;
import android.util.Log;

/**
 * Created by shankari on 1/18/15.
 */
public class MockLocationBroadcastChecker extends BroadcastChecker {
    private static final String TAG = "MockLocationBrdcstChker";
    private int code1;
    private int code2;

    public MockLocationBroadcastChecker(String broadcastAction, int code1, int code2) {
        super(broadcastAction);
        this.code1 = code1;
        this.code2 = code2;
        Log.d(TAG, "Creation done with "+broadcastAction+", "+code1+", "+code2);
    }

    public boolean isMatchingIntent(Intent intent) {
        if (super.isMatchingIntent(intent)) {
            int iCode1 = intent.getIntExtra(LocationUtils.KEY_EXTRA_CODE1, 0);
            int iCode2 = intent.getIntExtra(LocationUtils.KEY_EXTRA_CODE2, 0);
            Log.d(TAG, "intent string matches, checking extra codes from intent "+
                iCode1+", "+iCode2+" against stored "+code1+", "+code2);

            if (iCode1 == code1 &&
                    iCode2 == code2) {
                return true;
            }
        }
        return false;
    }
}

Change the tag to fit the size requirements of the log class


/*
 * oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

package org.xdi.model.custom.script.type.client;

import java.util.Map;

import org.xdi.model.SimpleCustomProperty;
import org.xdi.model.custom.script.type.BaseExternalType;

/**
 * Base interface for external custom client registration python script
 *
 * @author Yuriy Movchan Date: 11/11/2014
 */
public interface ClientRegistrationType extends BaseExternalType {

    boolean updateClient(Object registerRequest, Object client, Map<String, SimpleCustomProperty> configurationAttributes);

}

/*
 * oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

package org.xdi.model.custom.script.type.client;

import java.util.Map;

import org.xdi.model.SimpleCustomProperty;
import org.xdi.model.custom.script.type.BaseExternalType;

/**
 * Base interface for external custom client registration python script
 *
 * @author Yuriy Movchan Date: 11/11/2014
 */
public interface ClientRegistrationType extends BaseExternalType {

    public boolean createClient(Object registerRequest, Object client, Map<String, SimpleCustomProperty> configurationAttributes);

    public boolean updateClient(Object registerRequest, Object client, Map<String, SimpleCustomProperty> configurationAttributes);

}

Add create client method to client registration script


/*
 * Copyright © 2017 the original authors (http://cereebro.io)
 *
 * 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 io.cereebro.sample.server;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import io.cereebro.server.EnableCereebroServer;

@SpringBootApplication
@EnableCereebroServer
public class CereebroSampleServerEurekaClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(CereebroSampleServerEurekaClientApplication.class, args);
    }

}

/*
 * Copyright © 2017 the original authors (http://cereebro.io)
 *
 * 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 io.cereebro.sample.server;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import io.cereebro.server.EnableCereebroServer;

@SpringBootApplication
@EnableCereebroServer
@EnableDiscoveryClient
public class CereebroSampleServerEurekaClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(CereebroSampleServerEurekaClientApplication.class, args);
    }

}

Add missing @EnableDiscoveryClient in standalone server sample


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.geronimo.gshell.event;

/**
 * Adapter for typed {@link Event} processing.
 *
 * @version $Rev$ $Date$
 */
public abstract class EventAdapter<T extends Event>
    implements EventListener
{
    @SuppressWarnings({"unchecked"})
    public void onEvent(final Event event) throws Exception {
        T targetEvent = null;

        // HACK: Can't check the type from T, so just handle the CCE, might not be very efficent though :-(
        try {
            targetEvent = (T)event;
        }
        catch (ClassCastException ignore) {}

        if (targetEvent != null) {
            handleEvent(targetEvent);
        }
    }

    protected abstract void handleEvent(T event) throws Exception;
}

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.geronimo.gshell.event;

/**
 * Adapter for typed {@link Event} processing.
 *
 * @version $Rev$ $Date$
 */
public abstract class EventAdapter<T extends Event>
    implements EventListener
{
    @SuppressWarnings({"unchecked"})
    public void onEvent(final Event event) throws Exception {
        assert event != null;

        // HACK: Can't check the type from T, so just handle the CCE, might not be very efficent though :-(
        try {
            handleEvent((T)event);
        }
        catch (ClassCastException ignore) {}
    }

    protected abstract void handleEvent(T event) throws Exception;
}

Revert back to first hack attempt, maybe need to implement a better event subscription model

git-svn-id: cd28ba526fba5b39766c0a4e72305690b33c2c6e@702414 13f79535-47bb-0310-9956-ffa450edef68


package com.adaptionsoft.games.uglytrivia;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.mock;

public class PlayersTest {

    public static final String PLAYER_ONE = "Thomas";
    public static final String PLAYER_TWO = "Peter";
    public static final String ANY_PLAYER = "Erik";

    private PlayerUI ui = mock(PlayerUI.class);
    private Players players = new Players(ui);

    @Before
    public void addPlayers() {
        players.add(PLAYER_ONE);
        players.add(PLAYER_TWO);
    }

    @Test
    public void shouldAddOnePlayer() {
        assertThat(players.size(), is(2));

        players.add(TestPlayer.named(ANY_PLAYER));

        assertThat(players.size(), is(3));
    }

    @Test(expected = IllegalAccessException.class)
    @Ignore("not implemented")
    public void shouldFailForMoreThanSixPlayers() {
        players.add(ANY_PLAYER);
        players.add(ANY_PLAYER);
        players.add(ANY_PLAYER);
        players.add(ANY_PLAYER);
        players.add("one too many");
    }
}

package com.adaptionsoft.games.uglytrivia;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.mock;

public class PlayersTest {

    public static final String PLAYER_ONE = "Thomas";
    public static final String PLAYER_TWO = "Peter";
    public static final String ANY_PLAYER = "Erik";

    // TODO minor duplication in all Player tests for creating the Players instance.
    private PlayerUI ui = mock(PlayerUI.class);
    private Players players = new Players(ui);

    @Before
    public void addPlayers() {
        players.add(PLAYER_ONE);
        players.add(PLAYER_TWO);
    }

    @Test
    public void shouldAddOnePlayer() {
        assertThat(players.size(), is(2));

        players.add(TestPlayer.named(ANY_PLAYER));

        assertThat(players.size(), is(3));
    }

    @Test(expected = IllegalAccessException.class)
    @Ignore("not implemented")
    public void shouldFailForMoreThanSixPlayers() {
        players.add(ANY_PLAYER);
        players.add(ANY_PLAYER);
        players.add(ANY_PLAYER);
        players.add(ANY_PLAYER);
        players.add("one too many");
    }
}

Add todo about minor duplication.

Add todo about minor duplication.


package com.example;

public class SimpleCraps implements BettingGame {

	@Override
	public int playGame(int betAmount) {
		// TODO Add your code here. Return the amount the user won (or a negative number if they lost!)

		//To create a die, use:
		Die die = new Die();

		//To roll the die you created, use:
		int rollResult = die.roll();

		//If the result is a draw, return 0:
		return 0;

		//If the result is a win, return betAmount:
		//return betAmount;

		//If the result is a loss, return -betAmount:
		//return -betAmount;
	}

	@Override
	public String getGameName() {
		return "SimpleCraps";
	}

}

package com.example;

public class SimpleCraps implements BettingGame {

	@Override
	public int playGame(int betAmount) {
		// TODO Add your code here. Return the amount the user won (or a negative number if they lost!)

		//To create a die, use:
		//Die die = new Die();

		//To roll the die you created, use:
		//int rollResult = die.roll();

		//If the result is a win, return betAmount:
		//return betAmount;

		//If the result is a loss, return -betAmount:
		//return -betAmount;

		//If the result is a draw, return 0:
		return 0;
	}

	@Override
	public String getGameName() {
		return "SimpleCraps";
	}

}

Comment out a couple of lines

Comment out a couple of lines


package org.jboss.forge.addon.parser.java.beans;

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

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet;
import org.jboss.forge.addon.parser.java.resources.JavaResource;
import org.jboss.forge.addon.parser.java.resources.JavaResourceVisitor;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.resource.visit.VisitContext;
import org.jboss.forge.roaster.model.source.JavaSource;

public class ProjectOperations
{
   public List<JavaResource> getProjectClasses(Project project)
   {
      final List<JavaResource> classes = new ArrayList<>();
      if (project != null)
      {
         project.getFacet(JavaSourceFacet.class).visitJavaSources(new JavaResourceVisitor()
         {

            @Override
            public void visit(VisitContext context, JavaResource resource)
            {
               try
               {
                  JavaSource<?> javaType = resource.getJavaType();
                  if (javaType.isClass())
                  {
                     classes.add(resource);
                  }
               }
               catch (FileNotFoundException e)
               {
                  // ignore
               }
            }
         });
      }
      return classes;

   }
}

package org.jboss.forge.addon.parser.java.beans;

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

import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet;
import org.jboss.forge.addon.parser.java.resources.JavaResource;
import org.jboss.forge.addon.parser.java.resources.JavaResourceVisitor;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.resource.visit.VisitContext;
import org.jboss.forge.roaster.model.source.JavaSource;

/**
 * @author Lincoln Baxter, III
 */
public class ProjectOperations
{
   public List<JavaResource> getProjectClasses(Project project)
   {
      final List<JavaResource> classes = new ArrayList<>();
      if (project != null)
      {
         project.getFacet(JavaSourceFacet.class).visitJavaSources(new JavaClassSourceVisitor(classes));
      }
      return classes;
   }

   private static class JavaClassSourceVisitor extends JavaResourceVisitor
   {
      private final List<JavaResource> classes;

      private JavaClassSourceVisitor(List<JavaResource> classes)
      {
         this.classes = classes;
      }

      @Override
      public void visit(VisitContext context, JavaResource resource)
      {
         try
         {
            JavaSource<?> javaType = resource.getJavaType();
            if (javaType.isClass())
            {
               classes.add(resource);
            }
         }
         catch (FileNotFoundException e)
         {
            // ignore
         }
      }
   }
}

FORGE-1848: Fix CDI explosions. Weld doesn't like Anonmymous classes sometimes for some reason?


/*
 * Copyright 2008-2013 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.broadleafcommerce.common.presentation.client;

/**
 *
 * @author jfischer
 *
 */
public enum SupportedFieldType {
    UNKNOWN,
    ID,
    BOOLEAN,
    DATE,
    INTEGER,
    DECIMAL,
    STRING,
    PASSWORD,
    PASSWORD_CONFIRM,
    EMAIL,
    FOREIGN_KEY,
    ADDITIONAL_FOREIGN_KEY,
    MONEY,
    BROADLEAF_ENUMERATION,
    EXPLICIT_ENUMERATION,
    EMPTY_ENUMERATION,
    DATA_DRIVEN_ENUMERATION,
    HTML,
    HTML_BASIC,
    UPLOAD,
    HIDDEN,
    ASSET_URL,
    ASSET_LOOKUP,
    MEDIA,
    RULE_SIMPLE,
    RULE_WITH_QUANTITY,
    STRING_LIST,
    IMAGE
}

/*
 * Copyright 2008-2013 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.broadleafcommerce.common.presentation.client;

/**
 *
 * @author jfischer
 *
 */
public enum SupportedFieldType {
    UNKNOWN,
    ID,
    BOOLEAN,
    DATE,
    INTEGER,
    DECIMAL,
    STRING,
    PASSWORD,
    PASSWORD_CONFIRM,
    EMAIL,
    FOREIGN_KEY,
    ADDITIONAL_FOREIGN_KEY,
    MONEY,
    BROADLEAF_ENUMERATION,
    EXPLICIT_ENUMERATION,
    EMPTY_ENUMERATION,
    DATA_DRIVEN_ENUMERATION,
    HTML,
    HTML_BASIC,
    UPLOAD,
    HIDDEN,
    ASSET_URL,
    ASSET_LOOKUP,
    MEDIA,
    RULE_SIMPLE,
    RULE_WITH_QUANTITY,
    STRING_LIST,
    IMAGE,
    COLOR
}

Add COLOR as an available field type

Add COLOR as an available field type


package info.u_team.u_team_test.data.provider;

import info.u_team.u_team_core.data.*;
import info.u_team.u_team_test.init.*;

public class TestItemModelsProvider extends CommonItemModelsProvider {

	public TestItemModelsProvider(GenerationData data) {
		super(data);
	}

	@Override
	protected void registerModels() {
		// Items
		simpleGenerated(TestItems.BASIC.get());
		simpleGenerated(TestItems.BASIC_FOOD.get());
		simpleGenerated(TestItems.BETTER_ENDERPEARL.get());
		iterateItems(TestItems.BASIC_TOOL, this::simpleHandheld);
		iterateItems(TestItems.BASIC_ARMOR, this::simpleGenerated);
		// Blocks
		simpleBlock(TestBlocks.BASIC.get());
		simpleBlock(TestBlocks.BASIC_TILEENTITY.get());
		simpleBlock(TestBlocks.BASIC_ENERGY_CREATOR.get());
		simpleBlock(TestBlocks.BASIC_FLUID_INVENTORY.get());
	}

}

package info.u_team.u_team_test.data.provider;

import info.u_team.u_team_core.data.*;
import info.u_team.u_team_test.init.*;

public class TestItemModelsProvider extends CommonItemModelsProvider {

	public TestItemModelsProvider(GenerationData data) {
		super(data);
	}

	@Override
	protected void registerModels() {
		// Items
		simpleGenerated(TestItems.BASIC.get());
		simpleGenerated(TestItems.BASIC_FOOD.get());
		simpleGenerated(TestItems.BETTER_ENDERPEARL.get());
		iterateItems(TestItems.BASIC_TOOL, this::simpleHandheld);
		iterateItems(TestItems.BASIC_ARMOR, this::simpleGenerated);
		spawnEgg(TestItems.TEST_LIVING_SPAWN_EGG.get());
		// Blocks
		simpleBlock(TestBlocks.BASIC.get());
		simpleBlock(TestBlocks.BASIC_TILEENTITY.get());
		simpleBlock(TestBlocks.BASIC_ENERGY_CREATOR.get());
		simpleBlock(TestBlocks.BASIC_FLUID_INVENTORY.get());
	}

}

Add generation for spawn egg

Add generation for spawn egg


package io.doist.recyclerviewext.click_listeners;

import android.support.v7.widget.RecyclerView;
import android.view.View;

public class ClickableViewHolder extends RecyclerView.ViewHolder {
    public ClickableViewHolder(View itemView, OnItemClickListener onItemClickListener,
                               OnItemLongClickListener onItemLongClickListener) {
        super(itemView);

        setClickListeners(onItemClickListener, onItemLongClickListener);
    }

    private void setClickListeners(final OnItemClickListener onItemClickListener,
                                   final OnItemLongClickListener onItemLongClickListener) {
        if (onItemClickListener != null) {
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onItemClickListener.onItemClick(ClickableViewHolder.this);
                }
            });
        }

        if (onItemLongClickListener != null) {
            itemView.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    onItemLongClickListener.onItemLongClick(ClickableViewHolder.this);
                    return true;
                }
            });
        }
    }
}

package io.doist.recyclerviewext.click_listeners;

import android.support.v7.widget.RecyclerView;
import android.view.View;

public class ClickableViewHolder extends RecyclerView.ViewHolder {
    public ClickableViewHolder(View itemView, OnItemClickListener onItemClickListener) {
        this(itemView, onItemClickListener, null);
    }

    public ClickableViewHolder(View itemView, OnItemClickListener onItemClickListener,
                               OnItemLongClickListener onItemLongClickListener) {
        super(itemView);

        setClickListeners(onItemClickListener, onItemLongClickListener);
    }

    private void setClickListeners(final OnItemClickListener onItemClickListener,
                                   final OnItemLongClickListener onItemLongClickListener) {
        if (onItemClickListener != null) {
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onItemClickListener.onItemClick(ClickableViewHolder.this);
                }
            });
        }

        if (onItemLongClickListener != null) {
            itemView.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    onItemLongClickListener.onItemLongClick(ClickableViewHolder.this);
                    return true;
                }
            });
        }
    }
}

Add extra constructor for backwards compatibility


package com.example.textmate.sqlite.models;

import java.lang.String;

public class textMateScores {

}

package com.example.textmate.sqlite.models;

import java.lang.String;

public class textMateScores {
    private int id, numUpdate;
    private int numScores = 30;
    private String name;
    private double[] score = new double[numScores];

   //Constructor
   //Empty Constructor
    public textMateScores(){}
    //Base Constructor
    public textMateScores(int id,String name,double[] score, int numUpdate){
        this.id=id;
        this.name=name;
        for(int i=0;i<numScores;i++){
        this.score[i]=0;}
        this.numUpdate=0;
    }

    //Class Methods
    public int fetchID(){return this.id;}
    public void setID(int ID){this.id=ID;}

    public String fetchName(){return this.name;}
    public void setName(String newName){this.name=newName;}

    public int fetchNumUpdate(){return this.numUpdate;}
    public void setNumUpdate(int newNumUpdate){this.numUpdate=newNumUpdate;}

    public double fetchScore(int posScore){return this.score[(this.numUpdate % numScores)];}
    public void setScore(double newScore){
        this.score[this.numUpdate%numScores] = newScore;
        this.setNumUpdate(this.numUpdate+1);
    }

}

Update to Model Class for Database

Update to Model Class for Database


package test;

import models.ContactDB;
import org.junit.Test;
import static org.fest.assertions.Assertions.assertThat;
import play.mvc.Content;
import static play.test.Helpers.contentType;
import static play.test.Helpers.contentAsString;

/**
 *
 * Simple (JUnit) tests that can call all parts of a play app. If you are interested in mocking a whole application, see
 * the wiki for more details.
 *
 */
public class ApplicationTest {

  /**
   * Illustrates a simple test.
   */
  @Test
  public void simpleCheck() {
    int a = 1 + 1;
    assertThat(a).isEqualTo(2);
  }

  /**
   * Illustrates how to render a template for testing.
   */
  @Test
  public void renderTemplate() {
    Content html = views.html.Index.render(ContactDB.getContacts());
    assertThat(contentType(html)).isEqualTo("text/html");
    assertThat(contentAsString(html)).contains("home page");
  }
}

package test;

import org.junit.Test;
import static org.fest.assertions.Assertions.assertThat;
import play.mvc.Content;
import static play.test.Helpers.contentType;
import static play.test.Helpers.contentAsString;

/**
 *
 * Simple (JUnit) tests that can call all parts of a play app. If you are interested in mocking a whole application, see
 * the wiki for more details.
 *
 */
public class ApplicationTest {

  /**
   * Illustrates a simple test.
   */
  @Test
  public void simpleCheck() {
    int a = 1 + 1;
    assertThat(a).isEqualTo(2);
  }

  /**
   * Illustrates how to render a template for testing.
   */
  @Test
  public void renderTemplate() {
    Content html = views.html.Index.render("Welcome to the home page.");
    assertThat(contentType(html)).isEqualTo("text/html");
    assertThat(contentAsString(html)).contains("home page");
  }
}

Revert "Fixed error in test package."

Revert "Fixed error in test package."

This reverts commit 39bacc609f4a1ffd64f5469f32b1384cf56f9610.


package dev.nincodedo.ninbot.components.reaction;

import lombok.Data;
import lombok.NoArgsConstructor;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

import java.util.List;

@NoArgsConstructor
@Data
abstract class ReactionResponse {

    protected String response;
    protected String target;
    protected List<String> responses;
    protected ReactionMatchType reactionMatchType;

    public ReactionResponse(ReactionResponse reactionResponse) {
        this.response = reactionResponse.response;
        this.target = reactionResponse.target;
        this.responses = reactionResponse.responses;
        this.reactionMatchType = reactionResponse.reactionMatchType;
    }

    abstract void react(Message message, MessageChannel channel);

    boolean canRespond(MessageReceivedEvent event) {
        return switch (reactionMatchType) {
            case EXACT -> getTarget()
                    .equalsIgnoreCase(event.getMessage().getContentStripped());
            case CONTAINS -> event.getMessage()
                    .getContentStripped()
                    .toLowerCase()
                    .contains(getTarget()
                            .toLowerCase());
            case REGEX -> event.getMessage().getContentStripped().matches(getTarget());
        };
    }
}

package dev.nincodedo.ninbot.components.reaction;

import lombok.Data;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

import java.util.List;

@Data
class ReactionResponse {

    protected String response;
    protected String target;
    protected List<String> responses;
    protected ReactionMatchType reactionMatchType;

    public ReactionResponse() {
    }

    public ReactionResponse(ReactionResponse reactionResponse) {
        this.response = reactionResponse.response;
        this.target = reactionResponse.target;
        this.responses = reactionResponse.responses;
        this.reactionMatchType = reactionResponse.reactionMatchType;
    }

    void react(Message message, MessageChannel channel) {
        //NO-OP
    }

    boolean canRespond(MessageReceivedEvent event) {
        return switch (reactionMatchType) {
            case EXACT -> getTarget()
                    .equalsIgnoreCase(event.getMessage().getContentStripped());
            case CONTAINS -> event.getMessage()
                    .getContentStripped()
                    .toLowerCase()
                    .contains(getTarget()
                            .toLowerCase());
            case REGEX -> event.getMessage().getContentStripped().matches(getTarget());
        };
    }
}

Fix loading issue for reactions

Fix loading issue for reactions


/* This file is part of VoltDB.
 * Copyright (C) 2008-2017 VoltDB Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

/**
 * A fake use case intended for use verifying that 'voltdb init --classes' works with non-trivial use cases.
 * The theme is querying translations for 'Hello' in different languages.
 */
package fakeusecase.greetings;

/* This file is part of VoltDB.
 * Copyright (C) 2008-2017 VoltDB Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

/**
 * A fake use case intended for use verifying that 'voltdb init --classes' works with non-trivial use cases.
 * The theme is querying translations for 'Hello' in different languages.
 */
package org.voltdb_testprocs.fakeusecase.greetings;

Fix package name to keep Eclipse happy.

Fix package name to keep Eclipse happy.


package net.ceos.project.poi.annotated.core;

import java.lang.annotation.Annotation;

import net.ceos.project.poi.annotated.annotation.XlsElement;
import net.ceos.project.poi.annotated.annotation.XlsFreeElement;

public interface XlsElementFactory {

	static XlsElement build(XlsFreeElement xlsAnnotation) {
		return new XlsElement() {

			@Override
			public Class<? extends Annotation> annotationType() {
				return xlsAnnotation.annotationType();
			}

			@Override
			public String transformMask() {
				return xlsAnnotation.transformMask();
			}

			@Override
			public String title() {
				return xlsAnnotation.title();
			}

			@Override
			public int position() {
				return 0;
			}

			@Override
			public boolean isFormula() {
				return xlsAnnotation.isFormula();
			}

			@Override
			public String formula() {
				return xlsAnnotation.formula();
			}

			@Override
			public String formatMask() {
				return xlsAnnotation.formatMask();
			}

			@Override
			public String decorator() {
				return xlsAnnotation.decorator();
			}

			@Override
			public String customizedRules() {
				return xlsAnnotation.customizedRules();
			}

			@Override
			public String comment() {
				return xlsAnnotation.comment();
			}

			@Override
			public String commentRules() {
				return "";
			}
		};
	}
}

package net.ceos.project.poi.annotated.core;

import java.lang.annotation.Annotation;

import net.ceos.project.poi.annotated.annotation.XlsElement;
import net.ceos.project.poi.annotated.annotation.XlsFreeElement;

public interface XlsElementFactory {

	static XlsElement build(XlsFreeElement xlsAnnotation) {
		return new XlsElement() {

			@Override
			public Class<? extends Annotation> annotationType() {
				return xlsAnnotation.annotationType();
			}

			@Override
			public String transformMask() {
				return xlsAnnotation.transformMask();
			}

			@Override
			public String title() {
				return xlsAnnotation.title();
			}

			@Override
			public int position() {
				return 0;
			}

			@Override
			public boolean isFormula() {
				return xlsAnnotation.isFormula();
			}

			@Override
			public String formula() {
				return xlsAnnotation.formula();
			}

			@Override
			public String formatMask() {
				return xlsAnnotation.formatMask();
			}

			@Override
			public String decorator() {
				return xlsAnnotation.decorator();
			}

			@Override
			public String customizedRules() {
				return xlsAnnotation.customizedRules();
			}

			@Override
			public String comment() {
				return xlsAnnotation.comment();
			}

			@Override
			public String commentRules() {
				return xlsAnnotation.commentRules();
			}
		};
	}
}

Add the commentRules to the factory

Add the commentRules to the factory


package com.insightfullogic.lambdabehave.expectations;

import org.hamcrest.Matcher;
import org.hamcrest.Matchers;

import static org.junit.Assert.assertThat;

/**
 * .
 */
public final class StringExpectation extends BoundExpectation<String> {
    public StringExpectation(final String str, final boolean positive) {
        super(str, positive);
    }

    public StringExpectation isEmptyString() {
        return matches(Matchers.isEmptyString());
    }

    public StringExpectation isEmptyOrNullString() {
        return matches(Matchers.isEmptyOrNullString());
    }

    public StringExpectation equalToIgnoringCase(final String expectedString) {
        return matches(Matchers.equalToIgnoringCase(expectedString));
    }

    public StringExpectation equalToIgnoringWhiteSpace(final String expectedString) {
        return matches(Matchers.equalToIgnoringWhiteSpace(expectedString));
    }

    public StringExpectation containsString(final String substring) {
        return matches(Matchers.containsString(substring));
    }

    public StringExpectation endsWith(final String suffix) {
        return matches(Matchers.endsWith(suffix));
    }

    public StringExpectation startsWith(final String prefix) {
        return matches(Matchers.startsWith(prefix));
    }

    private StringExpectation matches(final Matcher<String> matcher) {
        assertThat(objectUnderTest, matcher);
        return this;
    }
}

package com.insightfullogic.lambdabehave.expectations;

import org.hamcrest.Matcher;
import org.hamcrest.Matchers;

import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

/**
 * .
 */
public final class StringExpectation extends BoundExpectation<String> {
    public StringExpectation(final String str, final boolean positive) {
        super(str, positive);
    }

    public StringExpectation isEmptyString() {
        return matches(Matchers.isEmptyString());
    }

    public StringExpectation isEmptyOrNullString() {
        return matches(Matchers.isEmptyOrNullString());
    }

    public StringExpectation equalToIgnoringCase(final String expectedString) {
        return matches(Matchers.equalToIgnoringCase(expectedString));
    }

    public StringExpectation equalToIgnoringWhiteSpace(final String expectedString) {
        return matches(Matchers.equalToIgnoringWhiteSpace(expectedString));
    }

    public StringExpectation containsString(final String substring) {
        return matches(Matchers.containsString(substring));
    }

    public StringExpectation endsWith(final String suffix) {
        return matches(Matchers.endsWith(suffix));
    }

    public StringExpectation startsWith(final String prefix) {
        return matches(Matchers.startsWith(prefix));
    }

    private StringExpectation matches(final Matcher<String> matcher) {
        assertThat(objectUnderTest, matcher);
        return this;
    }

    public StringExpectation matches(String regex) {
        assertTrue(objectUnderTest.matches(regex));
        return this;
    }

}

Add method to check if a string matches a regular expression


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.opentransport.rdfmapper.nmbs;

import java.net.URL;

import com.google.transit.realtime.GtfsRealtime.FeedEntity;
import com.google.transit.realtime.GtfsRealtime.FeedMessage;

/**
 *
 * @author timtijssens
 */
public class GtfsRealtimeExample {

    public GtfsRealtimeExample(String filename) throws Exception {
        System.out.println("Testing Real Time Example");
        URL url = new URL("http://localhost:8000/" +filename);
        FeedMessage feed = FeedMessage.parseFrom(url.openStream());
        for (FeedEntity entity : feed.getEntityList()) {
          if (entity.hasTripUpdate()) {
            System.out.println(entity.getTripUpdate());
          }
            if (entity.hasAlert()) {
                System.out.println(entity.getAlert());

            }
        }
      }

}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.opentransport.rdfmapper.nmbs;

import java.net.URL;

import com.google.transit.realtime.GtfsRealtime.FeedEntity;
import com.google.transit.realtime.GtfsRealtime.FeedMessage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 *
 * @author timtijssens
 */
public class GtfsRealtimeExample {

    public GtfsRealtimeExample(String filename) throws Exception {
        System.out.println("Testing Real Time Example");

        InputStream is;

        try {
            is = new FileInputStream(filename);
            FeedMessage feed = FeedMessage.parseFrom(is);

            for (FeedEntity entity : feed.getEntityList()) {
              if (entity.hasTripUpdate()) {
                System.out.println(entity.getTripUpdate());
              }
                if (entity.hasAlert()) {
                    System.out.println(entity.getAlert());
                }
            }
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
      }
}

Test your fresh generated trip_updates.pb and service_alerts.pb locally