package com.yahoo.concurrent.classlock;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BooleanSupplier;

/**
 * @author valerijf
 */
public class ClassLocking {
    private final Map<Class<?>, ClassLock> classLocks = new HashMap<>();
    private final Object monitor = new Object();

    public ClassLock lock(Class<?> clazz) {
        return lockWhile(clazz, () -> true);
    }

    public ClassLock lockWhile(Class<?> clazz, BooleanSupplier interruptCondition) {
        synchronized (monitor) {
            while (classLocks.containsKey(clazz)) {
                try {
                    monitor.wait();
                } catch (InterruptedException ignored) {
                }

                if (!interruptCondition.getAsBoolean()) {
                    throw new LockInterruptException();
                }
            }

            ClassLock classLock = new ClassLock(this, clazz);
            classLocks.put(clazz, classLock);
            return classLock;
        }
    }

    void unlock(Class<?> clazz, ClassLock classLock) {
        synchronized (monitor) {
            if (classLock.equals(classLocks.get(clazz))) {
                classLocks.remove(clazz);
                monitor.notifyAll();
            } else {
                throw new IllegalArgumentException("Lock has already been released");
            }
        }
    }

    public void interrupt() {
        synchronized (monitor) {
            monitor.notifyAll();
        }
    }
}

package com.yahoo.concurrent.classlock;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BooleanSupplier;

/**
 * @author valerijf
 */
public class ClassLocking {
    private final Map<String, ClassLock> classLocks = new HashMap<>();
    private final Object monitor = new Object();

    public ClassLock lock(Class<?> clazz) {
        return lockWhile(clazz, () -> true);
    }

    public ClassLock lockWhile(Class<?> clazz, BooleanSupplier interruptCondition) {
        synchronized (monitor) {
            while (classLocks.containsKey(clazz.getName())) {
                try {
                    monitor.wait();
                } catch (InterruptedException ignored) {
                }

                if (!interruptCondition.getAsBoolean()) {
                    throw new LockInterruptException();
                }
            }

            ClassLock classLock = new ClassLock(this, clazz);
            classLocks.put(clazz.getName(), classLock);
            return classLock;
        }
    }

    void unlock(Class<?> clazz, ClassLock classLock) {
        synchronized (monitor) {
            if (classLock.equals(classLocks.get(clazz.getName()))) {
                classLocks.remove(clazz.getName());
                monitor.notifyAll();
            } else {
                throw new IllegalArgumentException("Lock has already been released");
            }
        }
    }

    public void interrupt() {
        synchronized (monitor) {
            monitor.notifyAll();
        }
    }
}

Use String as lock key


package editor.gui.ccp.handler;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.Arrays;
import java.util.stream.Collectors;

import javax.swing.TransferHandler;

import editor.database.card.Card;
import editor.gui.ccp.data.DataFlavors;
import editor.gui.editor.EditorFrame;

@SuppressWarnings("serial")
public class CardImportHandler extends TransferHandler implements ImportHandler
{
    private final EditorFrame editor;
    private final int id;

    public CardImportHandler(EditorFrame e, int i)
    {
        editor = e;
        id = i;
    }

    @Override
    public DataFlavor supportedFlavor()
    {
        return DataFlavors.cardFlavor;
    }

    @Override
    public boolean canImport(TransferSupport supp)
    {
        return supp.isDataFlavorSupported(supportedFlavor());
    }

    @Override
    public boolean importData(TransferSupport supp)
    {
        if (!canImport(supp))
            return false;
        else
        {
            try
            {
                var data = Arrays.stream((Card[])supp.getTransferable().getTransferData(supportedFlavor())).collect(Collectors.toSet());
                return editor.addCards(id, data, 1);
            }
            catch (UnsupportedFlavorException | IOException e)
            {
                return false;
            }
        }
    }
}

package editor.gui.ccp.handler;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.Arrays;
import java.util.stream.Collectors;

import javax.swing.TransferHandler;

import editor.database.card.Card;
import editor.gui.ccp.data.DataFlavors;
import editor.gui.editor.EditorFrame;

/**
 * Import handler for importing a list of single copies of cards.
 */
@SuppressWarnings("serial")
public class CardImportHandler extends TransferHandler implements ImportHandler
{
    /** Editor frame that is importing the cards. */
    private final EditorFrame editor;
    /** ID of the list to import cards to. */
    private final int id;

    /**
     * Create a new card import handler.
     *
     * @param e editor frame containing the deck to import cards into
     * @param i ID of the list in the deck to import into
     */
    public CardImportHandler(EditorFrame e, int i)
    {
        editor = e;
        id = i;
    }

    @Override
    public DataFlavor supportedFlavor()
    {
        return DataFlavors.cardFlavor;
    }

    @Override
    public boolean canImport(TransferSupport supp)
    {
        return supp.isDataFlavorSupported(supportedFlavor());
    }

    @Override
    public boolean importData(TransferSupport supp)
    {
        if (!canImport(supp))
            return false;
        else
        {
            try
            {
                var data = Arrays.stream((Card[])supp.getTransferable().getTransferData(supportedFlavor())).collect(Collectors.toSet());
                return editor.addCards(id, data, 1);
            }
            catch (UnsupportedFlavorException | IOException e)
            {
                return false;
            }
        }
    }
}

Add documentation to card import handler


package net.silentchaos512.gems.entity;

import java.util.List;

import com.google.common.collect.Lists;

import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Biomes;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.silentchaos512.lib.registry.SRegistry;

public class ModEntities {

  public static List<Class> nodePacketClasses = Lists.newArrayList();

  public static void init(SRegistry reg) {

    reg.registerEntity(EntityChaosProjectile.class, "ChaosProjectile", 64, 4, true);
    reg.registerEntity(EntityChaosProjectileHoming.class, "ChaosProjectileHoming", 64, 4, true);
    reg.registerEntity(EntityChaosProjectileSweep.class, "ChaosProjectileSweep", 64, 4, true);

    reg.registerEntity(EntityThrownTomahawk.class, "ThrownTomahawk");

    reg.registerEntity(EntityEnderSlime.class, "EnderSlime", 64, 4, false, 0x003333, 0xAA00AA);
    EntityRegistry.addSpawn(EntityEnderSlime.class, 50, 1, 4, EnumCreatureType.MONSTER, Biomes.SKY);
  }
}

package net.silentchaos512.gems.entity;

import java.util.List;

import com.google.common.collect.Lists;

import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Biomes;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.silentchaos512.lib.registry.SRegistry;

public class ModEntities {

  public static List<Class> nodePacketClasses = Lists.newArrayList();

  public static void init(SRegistry reg) {

    reg.registerEntity(EntityChaosProjectile.class, "ChaosProjectile", 64, 4, true);
    reg.registerEntity(EntityChaosProjectileHoming.class, "ChaosProjectileHoming", 64, 4, true);
    reg.registerEntity(EntityChaosProjectileSweep.class, "ChaosProjectileSweep", 64, 4, true);

    reg.registerEntity(EntityThrownTomahawk.class, "ThrownTomahawk");

    reg.registerEntity(EntityEnderSlime.class, "EnderSlime", 64, 4, false, 0x003333, 0xAA00AA);
    EntityRegistry.addSpawn(EntityEnderSlime.class, 10, 1, 4, EnumCreatureType.MONSTER, Biomes.SKY);
  }
}

Make ender slime spawn rate more sane


package org.babblelang.engine.impl.natives.java;

import org.babblelang.engine.impl.Callable;
import org.babblelang.engine.impl.Interpreter;
import org.babblelang.engine.impl.Namespace;
import org.babblelang.engine.impl.Scope;
import org.babblelang.parser.BabbleParser;

import java.util.HashMap;
import java.util.Map;

public class ImportFunction implements Callable<JavaPackage> {
    private final Map<String, JavaPackage> packages = new HashMap<>();

    public Namespace bindParameters(Interpreter interpreter, BabbleParser.CallContext callSite, Namespace parent, Parameters parameters) {
        Namespace namespace = parent.enter(null);
        Object first = parameters.values().iterator().next();
        namespace.define("name", true).set(first);
        return namespace;
    }

    public JavaPackage call(Interpreter interpreter, BabbleParser.CallContext callSite, Scope scope) {
        String name = (String) scope.get("name").get();
        return getPackage(name);
    }

    public JavaPackage getPackage(String name) {
        JavaPackage result = packages.computeIfAbsent(name, name -> new JavaPackage(this, name));
        return result;
    }
}

package org.babblelang.engine.impl.natives.java;

import org.babblelang.engine.impl.Callable;
import org.babblelang.engine.impl.Interpreter;
import org.babblelang.engine.impl.Namespace;
import org.babblelang.engine.impl.Scope;
import org.babblelang.parser.BabbleParser;

import java.util.HashMap;
import java.util.Map;

public class ImportFunction implements Callable<JavaPackage> {
    private final Map<String, JavaPackage> packages = new HashMap<>();

    public Namespace bindParameters(Interpreter interpreter, BabbleParser.CallContext callSite, Namespace parent, Parameters parameters) {
        Namespace namespace = parent.enter(null);
        Object first = parameters.values().iterator().next();
        namespace.define("name", true).set(first);
        return namespace;
    }

    public JavaPackage call(Interpreter interpreter, BabbleParser.CallContext callSite, Scope scope) {
        String name = (String) scope.get("name").get();
        return getPackage(name);
    }

    public JavaPackage getPackage(String name) {
        return packages.computeIfAbsent(name, n -> new JavaPackage(this, n));
    }
}

Fix redeclaration of name in use of Map.computeIfAbsent.


package com.choonster.testmod3.tests;

/**
 * Runs this mod's tests.
 *
 * @author Choonster
 */
public class Tests {
	public static void runTests() {
		OreDictUtilTests.INSTANCE.test();
		NBTTagEndTests.INSTANCE.test();
	}
}

package com.choonster.testmod3.tests;

/**
 * Runs this mod's tests.
 *
 * @author Choonster
 */
public class Tests {
	public static void runTests() {
		OreDictUtilTests.INSTANCE.test();
//		NBTTagEndTests.INSTANCE.test();
	}
}

Disable NBT Tag End tests


package signature.display;

import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JPanel;

import signature.ColoredTree;

public class ColoredTreePanel extends JPanel {

    public int maxDepth;

    private DisplayableColoredTree displayTree;

    private boolean drawKey;

    public ColoredTreePanel(int width, int height) {
        this.setPreferredSize(new Dimension(width, height));
        this.drawKey = false;
        this.displayTree = new DisplayableColoredTree(width, height);
    }

    public ColoredTreePanel(ColoredTree tree, int width, int height) {
        displayTree = new DisplayableColoredTree(tree, width, height);
        this.drawKey = false;
        this.setPreferredSize(new Dimension(width, height));
    }

    public void setDrawKey(boolean drawKey) {
        this.drawKey = drawKey;
    }

    public void setTree(ColoredTree tree) {
        System.out.println("setting tree " + tree);
        this.displayTree.makeFromColoredTree(tree);
        this.displayTree.setDrawKey(drawKey);
        this.maxDepth = tree.getHeight();
    }

    public void paint(Graphics g) {
        this.displayTree.paint(g);
    }

}

package signature.display;

import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JPanel;

import signature.ColoredTree;

public class ColoredTreePanel extends JPanel {

    public int maxDepth;

    private DisplayableColoredTree displayTree;

    private boolean drawKey;

    public ColoredTreePanel(int width, int height) {
        this.setPreferredSize(new Dimension(width, height));
        this.drawKey = false;
        this.displayTree = new DisplayableColoredTree(width, height);
    }

    public ColoredTreePanel(ColoredTree tree, int width, int height) {
        displayTree = new DisplayableColoredTree(tree, width, height);
        this.drawKey = false;
        this.setPreferredSize(new Dimension(width, height));
    }

    public void setDrawKey(boolean drawKey) {
        this.drawKey = drawKey;
    }

    public void setTree(ColoredTree tree) {
        System.out.println("setting tree " + tree);
        this.displayTree.makeFromColoredTree(tree);
        this.displayTree.setDrawKey(drawKey);
        this.maxDepth = tree.getHeight();
    }

    public void paint(Graphics g) {
        if (displayTree != null) {
            this.displayTree.paint(g);
        }
    }

    public void clear() {
        this.displayTree = null;
    }

}

Make colored tree panel clearable


/* Copyright (c) 2013 OpenPlans. All rights reserved.
 * This code is licensed under the BSD New License, available at the root
 * application directory.
 */
package org.geogit.storage.neo4j;

import org.geogit.storage.GraphDatabase;

import com.google.inject.AbstractModule;

public class Neo4JModule extends AbstractModule {

    @Override
    protected void configure() {
        bind(GraphDatabase.class).to(Neo4JGraphDatabase.class);
    }

}

/* Copyright (c) 2013 OpenPlans. All rights reserved.
 * This code is licensed under the BSD New License, available at the root
 * application directory.
 */
package org.geogit.storage.neo4j;

import org.geogit.storage.GraphDatabase;

import com.google.inject.AbstractModule;
import com.google.inject.Scopes;

public class Neo4JModule extends AbstractModule {
    @Override
    protected void configure() {
        bind(GraphDatabase.class).to(Neo4JGraphDatabase.class).in(Scopes.SINGLETON);
    }
}

Use Singleton scope for Neo4JGraphDatabase


package io.quarkus.jsonb;

import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
import javax.inject.Singleton;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import javax.json.bind.JsonbConfig;

import io.quarkus.arc.DefaultBean;

@Singleton
public class JsonbProducer {

    @Produces
    @Dependent //JsonbConfig is not thread safe so it must not be made singleton.
    @DefaultBean
    public JsonbConfig jsonbConfig(Instance<JsonbConfigCustomizer> customizers) {
        JsonbConfig jsonbConfig = new JsonbConfig();
        for (JsonbConfigCustomizer customizer : customizers) {
            customizer.customize(jsonbConfig);
        }
        return jsonbConfig;
    }

    @Produces
    @Singleton
    @DefaultBean
    public Jsonb jsonb(JsonbConfig jsonbConfig) {
        return JsonbBuilder.create(jsonbConfig);
    }
}

package io.quarkus.jsonb;

import java.util.List;

import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Produces;
import javax.inject.Singleton;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import javax.json.bind.JsonbConfig;

import io.quarkus.arc.All;
import io.quarkus.arc.DefaultBean;

@Singleton
public class JsonbProducer {

    @Produces
    @Dependent //JsonbConfig is not thread safe so it must not be made singleton.
    @DefaultBean
    public JsonbConfig jsonbConfig(@All List<JsonbConfigCustomizer> customizers) {
        JsonbConfig jsonbConfig = new JsonbConfig();
        for (JsonbConfigCustomizer customizer : customizers) {
            customizer.customize(jsonbConfig);
        }
        return jsonbConfig;
    }

    @Produces
    @Singleton
    @DefaultBean
    public Jsonb jsonb(JsonbConfig jsonbConfig) {
        return JsonbBuilder.create(jsonbConfig);
    }
}

Make sure JsonbConfigCustomizers are sorted by @Priority


package com.kolinkrewinkel.BitLimitTweaks;

import java.util.*;
import com.google.common.base.Joiner;
import org.bukkit.ChatColor;
import org.bukkit.*;
import org.bukkit.plugin.Plugin;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import org.bukkit.block.*;

public class TweaksCommandExecutor implements CommandExecutor {
    private final BitLimitTweaks plugin;

    public TweaksCommandExecutor(BitLimitTweaks plugin) {
        this.plugin = plugin;
    }

    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender.hasPermission("BitLimitTweaks")) {

        } else {
            sender.sendMessage(ChatColor.RED + "You don't have permission to execute this command.");
        }
        return false;
    }
}

package com.kolinkrewinkel.BitLimitTweaks;

import java.util.*;
import com.google.common.base.Joiner;
import org.bukkit.ChatColor;
import org.bukkit.*;
import org.bukkit.plugin.Plugin;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import org.bukkit.block.*;

public class TweaksCommandExecutor implements CommandExecutor {
    private final BitLimitTweaks plugin;

    public TweaksCommandExecutor(BitLimitTweaks plugin) {
        this.plugin = plugin;
    }

    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender.hasPermission("BitLimitTweaks")) {
            if (args.length > 1) {
                if (args.equals("weatherDuration")) {
                    if (sender instanceof Player) {
                        Player player = (Player)sender;
                        player.getWorld().setWeatherDuration(args[1]);
                    }
                }
            }
        } else {
            sender.sendMessage(ChatColor.RED + "You don't have permission to execute this command.");
        }
        return false;
    }
}

Add a method to set the duration


package org.bricolages.streaming.preflight;

import java.util.StringJoiner;
import lombok.*;

class CreateTableGenerator {
    private StreamDefinitionEntry streamDef;
    CreateTableGenerator(StreamDefinitionEntry streamDef) {
        this.streamDef = streamDef;
    }

    String generate() {
        val sb = new StringBuilder();
        sb.append("--dest-table: ");
        sb.append(streamDef.getFullTableName());
        sb.append("\n\n");
        sb.append("create table $dest_table \n(");
        generateColumnDefinitionList(sb);
        sb.append("\n)\n;\n");

        return sb.toString();
    }

    void generateColumnDefinitionList(StringBuilder sb) {
        val sj = new StringJoiner("\n,");
        for (val columnDef: streamDef.getColumns()) {
            sj.add(generateColumnDefinition(columnDef));
        }
        sb.append(sj.toString());
    }

    String generateColumnDefinition(ColumnDefinitionEntry columnDef) {
        val sj = new StringJoiner(" ", " ", "");
        sj.add(columnDef.getColumName());
        sj.add(columnDef.getParams().getType());
        sj.add("encode");
        sj.add(columnDef.getParams().getEncoding().toString());

        return sj.toString();
    }
}

package org.bricolages.streaming.preflight;

import java.util.StringJoiner;
import lombok.*;

class CreateTableGenerator {
    private StreamDefinitionEntry streamDef;
    CreateTableGenerator(StreamDefinitionEntry streamDef) {
        this.streamDef = streamDef;
    }

    String generate() {
        val sb = new StringBuilder();
        sb.append("--dest-table: ");
        sb.append(streamDef.getFullTableName());
        sb.append("\n\n");
        sb.append("create table $dest_table \n(");
        generateColumnDefinitionList(sb);
        sb.append("\n)\n");
        sb.append("sortkey(jst_time)\n");
        sb.append(";\n");

        return sb.toString();
    }

    void generateColumnDefinitionList(StringBuilder sb) {
        val sj = new StringJoiner("\n,");
        for (val columnDef: streamDef.getColumns()) {
            sj.add(generateColumnDefinition(columnDef));
        }
        sb.append(sj.toString());
    }

    String generateColumnDefinition(ColumnDefinitionEntry columnDef) {
        val sj = new StringJoiner(" ", " ", "");
        sj.add(columnDef.getColumName());
        sj.add(columnDef.getParams().getType());
        sj.add("encode");
        sj.add(columnDef.getParams().getEncoding().toString());

        return sj.toString();
    }
}

Add sortkey to create table stmt


package com.annimon.jecp.se;

import com.annimon.jecp.ApplicationListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.WindowConstants;

/**
 *
 * @author aNNiMON
 */
public abstract class JecpApplication extends JFrame implements ApplicationListener, WindowListener {

    private final JecpPaintPanel panel;

    public JecpApplication(int width, int height) {
        addWindowListener(JecpApplication.this);
        setLocationByPlatform(true);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        onStartApp(width, height);
        panel = new JecpPaintPanel(this, width, height);
        add(panel);
        pack();

        setVisible(true);
    }

    @Override
    public void windowClosing(WindowEvent e) {
        onDestroyApp();
    }

    @Override
    public void windowDeactivated(WindowEvent e) {
        onPauseApp();
    }

    @Override
    public void windowOpened(WindowEvent e) { }

    @Override
    public void windowClosed(WindowEvent e) { }

    @Override
    public void windowIconified(WindowEvent e) { }

    @Override
    public void windowDeiconified(WindowEvent e) { }

    @Override
    public void windowActivated(WindowEvent e) { }

}

package com.annimon.jecp.se;

import com.annimon.jecp.ApplicationListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.WindowConstants;

/**
 *
 * @author aNNiMON
 */
public abstract class JecpApplication extends JFrame implements WindowListener {

    private final ApplicationListener listener;
    private final JecpPaintPanel panel;

    public JecpApplication(ApplicationListener listener, int width, int height) {
        this.listener = listener;
        addWindowListener(JecpApplication.this);
        setLocationByPlatform(true);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        listener.onStartApp(width, height);
        panel = new JecpPaintPanel(listener, width, height);
        add(panel);
        pack();

        setVisible(true);
    }

    @Override
    public void windowClosing(WindowEvent e) {
        listener.onDestroyApp();
    }

    @Override
    public void windowDeactivated(WindowEvent e) {
        listener.onPauseApp();
    }

    @Override
    public void windowOpened(WindowEvent e) { }

    @Override
    public void windowClosed(WindowEvent e) { }

    @Override
    public void windowIconified(WindowEvent e) { }

    @Override
    public void windowDeiconified(WindowEvent e) { }

    @Override
    public void windowActivated(WindowEvent e) { }

}

Change JecpApllication class in JECP-SE


/*
 * $Id$
 * $Revision$
 * $Date$
 *
 * ====================================================================
 * 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 wicket.util.time;

import junit.framework.Assert;
import junit.framework.TestCase;

/**
 * Test cases for this object
 * @author Jonathan Locke
 */
public final class TimeOfDayTest extends TestCase
{
    /**
     *
     */
    public void test()
    {
        Assert.assertTrue(TimeOfDay.MIDNIGHT.hour() == 0);
        Assert.assertTrue(TimeOfDay.valueOf(TimeOfDay.MIDNIGHT.next()).equals(TimeOfDay.MIDNIGHT));

        final TimeOfDay three = TimeOfDay.time(3, 0, TimeOfDay.PM);
        final TimeOfDay five = TimeOfDay.time(5, 0, TimeOfDay.PM);

        Assert.assertTrue(five.after(three));
    }
}

/*
 * $Id$
 * $Revision$
 * $Date$
 *
 * ====================================================================
 * 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 wicket.util.time;

import junit.framework.Assert;
import junit.framework.TestCase;

/**
 * Test cases for this object
 * @author Jonathan Locke
 */
public final class TimeOfDayTest extends TestCase
{
    /**
     *
     */
    public void test()
    {
        Assert.assertEquals(0, TimeOfDay.MIDNIGHT.hour());
        Assert.assertEquals(TimeOfDay.MIDNIGHT, TimeOfDay.valueOf(TimeOfDay.MIDNIGHT.next()));

        final TimeOfDay three = TimeOfDay.time(3, 0, TimeOfDay.PM);
        final TimeOfDay five = TimeOfDay.time(5, 0, TimeOfDay.PM);

        Assert.assertTrue(five.after(three));
    }
}

Use the appropriate methods for checking equality. This gives better results when debugging the errors.


package net.shadowfacts.foodies.item;

import cpw.mods.fml.common.registry.GameRegistry;

/**
 * Helper class for registering items.
 * @author shadowfacts
 */
public class FItems {
	// Foods
	public static Food toast;
	public static Food tomato;
	public static Food beefPattie;

	public static void preInit() {
		// Create Items
		toast = new Food(7, 0.7f).setUnlocalizedName("foodToast").setTextureName("foodToast");
		tomato = new Food(1, 0.1f).setUnlocalizedName("fruitTomato").setTextureName("fruitTomato");
		beefPattie = new Food(7, 0.4f).setUnlocalizedName("foodBeefPattie").setTextureName("foodBeefPattie");

		// Register items
		GameRegistry.registerItem(toast, "foodToast");
		GameRegistry.registerItem(tomato, "fruitTomato");
		GameRegistry.registerItem(beefPattie, "foodBeefPattie");
	}

	public static void load() {

	}

	public static void postInit() {

	}
}

package net.shadowfacts.foodies.item;

import cpw.mods.fml.common.registry.GameRegistry;

/**
 * Helper class for registering items.
 * @author shadowfacts
 */
public class FItems {
	// Foods
	public static Food toast;
	public static Food tomato;
	public static Food beefPattie;

	public static void preInit() {
		// Create Items
		toast = new Food(5, 0.3f).setUnlocalizedName("foodToast").setTextureName("foodToast");
		tomato = new Food(1, 0.1f).setUnlocalizedName("fruitTomato").setTextureName("fruitTomato");
		beefPattie = new Food(7, 0.4f).setUnlocalizedName("foodBeefPattie").setTextureName("foodBeefPattie");

		// Register items
		GameRegistry.registerItem(toast, "foodToast");
		GameRegistry.registerItem(tomato, "fruitTomato");
		GameRegistry.registerItem(beefPattie, "foodBeefPattie");
	}

	public static void load() {

	}

	public static void postInit() {

	}
}

Change hunger values for toast


package org.coffeebrew.lang.parser;

import com.intellij.lang.ASTNode;
import com.intellij.lang.PsiBuilder;
import com.intellij.lang.PsiParser;
import com.intellij.psi.impl.source.tree.PlainTextFileElement;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;

/**
 * Parser implementation for CoffeeScript language support
 *
 * @author Michael Kessler
 * @since 0.1.0
 */
public class CoffeeScriptParser implements PsiParser {

  @NotNull
  public ASTNode parse(IElementType root, PsiBuilder builder) {
    return new PlainTextFileElement(builder.getOriginalText());
  }

}

package org.coffeebrew.lang.parser;

import com.intellij.lang.ASTNode;
import com.intellij.lang.PsiBuilder;
import com.intellij.lang.PsiParser;
import com.intellij.psi.PlainTextTokenTypes;
import com.intellij.psi.impl.source.tree.PlainTextASTFactory;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;

/**
 * Parser implementation for CoffeeScript language support
 *
 * @author Michael Kessler
 * @since 0.1.0
 */
public class CoffeeScriptParser implements PsiParser {

  @NotNull
  public ASTNode parse(IElementType root, PsiBuilder builder) {
    return new PlainTextASTFactory().createLeaf(PlainTextTokenTypes.PLAIN_TEXT, builder.getOriginalText());
  }

}

Fix wrong AST Node parsing on idea-x


package com.indeed.proctor.service;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.indeed.proctor.common.model.Payload;
import com.indeed.proctor.common.model.TestBucket;

/**
 * Representation of TestBucket intended for serialization into JSON.
 *
 * Mostly a rewriting of TestBucket with a few extras like skipping nulls and included test version for caching.
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class JsonTestBucket {
    final private String name;
    final private int value;
    final private Object payload;
    final private int version;

    /**
     * Serializes the object using an existing bucket and a separate version.
     *
     * Version needs to be obtained outside of the bucket through ProctorResult.getTestVersions()
     */
    public JsonTestBucket(final TestBucket bucket, final int version) {
        name = bucket.getName();
        value = bucket.getValue();
        this.version = version;

        // The json serializer will automatically make this into whatever json type it should be.
        // So we don't have to worry about figuring out the type of the payload.
        // TODO: The serializer converts 0.0 to 0. Is this a problem?
        final Payload bucketPayload = bucket.getPayload();
        if (bucketPayload != null) {
            payload = bucket.getPayload().fetchAValue();
        } else {
            payload = null;
        }
    }

    public String getName() {
        return name;
    }

    public int getValue() {
        return value;
    }

    public Object getPayload() {
        return payload;
    }

    public int getVersion() {
        return version;
    }
}

package com.indeed.proctor.service;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.indeed.proctor.common.model.Payload;
import com.indeed.proctor.common.model.TestBucket;

/**
 * Representation of TestBucket intended for serialization into JSON.
 *
 * Mostly a rewriting of TestBucket with a few extras like skipping nulls and included test version for caching.
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class JsonTestBucket {
    final private String name;
    final private int value;
    final private Object payload;
    final private int version;

    /**
     * Serializes the object using an existing bucket and a separate version.
     *
     * Version needs to be obtained outside of the bucket through ProctorResult.getTestVersions()
     */
    public JsonTestBucket(final TestBucket bucket, final int version) {
        name = bucket.getName();
        value = bucket.getValue();
        this.version = version;

        // The json serializer will automatically make this into whatever json type it should be.
        // So we don't have to worry about figuring out the type of the payload.
        final Payload bucketPayload = bucket.getPayload();
        if (bucketPayload != null) {
            payload = bucket.getPayload().fetchAValue();
        } else {
            payload = null;
        }
    }

    public String getName() {
        return name;
    }

    public int getValue() {
        return value;
    }

    public Object getPayload() {
        return payload;
    }

    public int getVersion() {
        return version;
    }
}

Remove serializer 0.0->0 todo. Functionality is correct.


package com.kolinkrewinkel.BitLimitTweaks;

import java.util.*;
import com.google.common.base.Joiner;
import org.bukkit.ChatColor;
import org.bukkit.*;
import org.bukkit.plugin.Plugin;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import org.bukkit.block.*;

public class TweaksCommandExecutor implements CommandExecutor {
    private final BitLimitTweaks plugin;

    public TweaksCommandExecutor(BitLimitTweaks plugin) {
        this.plugin = plugin;
    }

    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender.hasPermission("BitLimitTweaks")) {
            if (args.length > 1) {
                if (args.equals("weatherDuration")) {
                    if (sender instanceof Player) {
                        Player player = (Player)sender;
                        player.getWorld().setWeatherDuration(Integer.parseInt(args[1]));
                    }
                }
            }
        } else {
            sender.sendMessage(ChatColor.RED + "You don't have permission to execute this command.");
        }
        return false;
    }
}

package com.kolinkrewinkel.BitLimitTweaks;

import java.util.*;
import com.google.common.base.Joiner;
import org.bukkit.ChatColor;
import org.bukkit.*;
import org.bukkit.plugin.Plugin;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import org.bukkit.block.*;

public class TweaksCommandExecutor implements CommandExecutor {
    private final BitLimitTweaks plugin;

    public TweaksCommandExecutor(BitLimitTweaks plugin) {
        this.plugin = plugin;
    }

    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender.hasPermission("BitLimitTweaks")) {
            if (args.length > 1) {
                if (args[0].equals("weatherDuration")) {
                    if (sender instanceof Player) {
                        Player player = (Player)sender;
                        player.getWorld().setWeatherDuration(Integer.parseInt(args[1]));
                        player.sendMessage(Integer.toString(player.getWorld().getWeatherDuration()));
                    }
                }
            }
        } else {
            sender.sendMessage(ChatColor.RED + "You don't have permission to execute this command.");
        }
        return false;
    }
}

Change parameter checking to make it you know.. check parameters


package com.example.android.miwok;

public class Word {

    private String mMiwokWord;
    private String mEnglishWord;

    // Constructor setter method
    // @params strings miwokWord and englishWord
    // Sets private strings mMiwokWord and mEnglishWord
    public Word(String miwokWord, String englishWord) {
        mMiwokWord = miwokWord;
        mEnglishWord = englishWord;
    } // Close method Word()

    // Getter method to retrieve private string mMiwokWord
    public String getmMiwokWord() {
        return mMiwokWord;
    }

    // Getter method to retrieve private string mEnglishWord
    public String getmEnglishWord() {
        return mEnglishWord;
    }

} // Close class Word

package com.example.android.miwok;

public class Word {

    private String mMiwokWord;
    private String mEnglishWord;
    private int mImageResourceId;

    // Constructor setter method
    // @params strings miwokWord and englishWord
    // Sets private strings mMiwokWord and mEnglishWord
    public Word(String miwokWord, String englishWord) {
        mMiwokWord = miwokWord;
        mEnglishWord = englishWord;
    } // Close method Word()

    public Word(String miwokWord, String englishWord, int imageResourceId) {
        mMiwokWord = miwokWord;
        mEnglishWord = englishWord;
        mImageResourceId = imageResourceId;
    } // Close method Word()

    // Getter method to retrieve private string mMiwokWord
    public String getmMiwokWord() {
        return mMiwokWord;
    }

    // Getter method to retrieve private string mEnglishWord
    public String getmEnglishWord() {
        return mEnglishWord;
    }

    // Getter method to retrieve private string mIcon;
    public int getmImageResourceId() { return mImageResourceId; }

} // Close class Word

Set mImageResourceId to type int. Add overload constructor to include in imageResourceId


package de.netpioneer.socialmedia.twitter.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.twitter.api.SearchResults;
import org.springframework.social.twitter.api.Tweet;
import org.springframework.social.twitter.api.Twitter;
import org.springframework.stereotype.Service;

@Service
public class TwitterService {

	@Autowired
	private Twitter twitter;

	public List<Tweet> findTweetsByKeyword(String keyword) {
		SearchResults searchResults = twitter.searchOperations().search(keyword, 100);
		List<Tweet> tweets = searchResults.getTweets();
		return tweets;
	}

}

package de.netpioneer.socialmedia.twitter.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.twitter.api.SearchParameters;
import org.springframework.social.twitter.api.SearchParameters.ResultType;
import org.springframework.social.twitter.api.SearchResults;
import org.springframework.social.twitter.api.Tweet;
import org.springframework.social.twitter.api.Twitter;
import org.springframework.stereotype.Service;

@Service
public class TwitterService {

	@Autowired
	private Twitter twitter;

	public List<Tweet> findTweetsByKeyword(String keyword) {
		SearchParameters searchParameters = new SearchParameters(keyword)
				.resultType(ResultType.RECENT)
				.lang("en")
				.count(100);
		SearchResults searchResults = twitter.searchOperations().search(searchParameters);
		List<Tweet> tweets = searchResults.getTweets();
		return tweets;
	}

}

Improve search to contain the 100 most recent tweets in English language.


package com.haw.projecthorse.android;

import android.os.Build;
import android.os.Bundle;
import android.view.View;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.haw.projecthorse.gamemanager.CoreGameMain;

public class AndroidLauncher extends AndroidApplication {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Hiermit wird die Android Navigation Bar ausgeblendet, zurckholen
		// geht ab Android 4.4 mit einem Swipe vom oberen Bildschirmrand nach unten

		if (Build.VERSION.SDK_INT >= 19) {
			View decorView = getWindow().getDecorView();
			decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
					| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
		}

		AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
		initialize(new CoreGameMain(), config);

	}
}

package com.haw.projecthorse.android;

import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.haw.projecthorse.gamemanager.CoreGameMain;

public class AndroidLauncher extends AndroidApplication {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Hiermit wird die Android Navigation Bar ausgeblendet, zur�ckholen
		// geht ab Android 4.4 mit einem Swipe vom oberen Bildschirmrand nach unten

		if (Build.VERSION.SDK_INT >= 19) {
			Window window = getWindow();
			if(window!=null){
			try {
				View decorView = window.getDecorView();
				decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
						| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
			} catch (Exception e) {
				// No navbar on device
			}

			}
		}

		AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
		initialize(new CoreGameMain(), config);

	}
}

Fix für Samsung Geräte ohne Navbar


package com.sb.elsinore.html;

import com.sb.elsinore.BrewServer;
import org.rendersnake.HtmlCanvas;
import org.rendersnake.Renderable;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;

import static org.rendersnake.HtmlAttributesFactory.id;
import static org.rendersnake.HtmlAttributesFactory.name;
import static org.rendersnake.HtmlAttributesFactory.value;

/**
 * Created by doug on 07/02/15.
 */
public class RecipeListForm implements Renderable {

    @Override
    public void renderOn(HtmlCanvas htmlCanvas) throws IOException {
        ArrayList<String> recipeList = BrewServer.getRecipeList();
        htmlCanvas.div(id("newTriggersForm"))
            .form()
                .select(name("type").class_("holo-spinner")
                .onClick("setRecipe(this);"));
            htmlCanvas.option(value("").selected_if(true))
                    .write("Select Recipe Type")
                    ._option();
            for (String entry: recipeList) {
                htmlCanvas.option(value(entry))
                        .write(entry)
                        ._option();
            }
            htmlCanvas._select()
        ._form()
        ._div()
        .div(id("recipeContent"))._div();
    }
}

package com.sb.elsinore.html;

import com.sb.elsinore.BrewServer;
import org.rendersnake.HtmlCanvas;
import org.rendersnake.Renderable;

import java.io.IOException;
import java.util.ArrayList;

import static org.rendersnake.HtmlAttributesFactory.id;
import static org.rendersnake.HtmlAttributesFactory.name;
import static org.rendersnake.HtmlAttributesFactory.value;

/**
 * Render a form allowing selection of the recipe.
 * Created by Doug Edey on 07/02/15.
 */
public class RecipeListForm implements Renderable {

    @Override
    public void renderOn(HtmlCanvas htmlCanvas) throws IOException {
        ArrayList<String> recipeList = BrewServer.getRecipeList();
        htmlCanvas.div(id("selectRecipeForm"))
            .form()
                .select(name("name").class_("holo-spinner")
                .onClick("setRecipe(this);"));
            htmlCanvas.option(value("").selected_if(true))
                    .write("Select Recipe")
                    ._option();
            for (String entry: recipeList) {
                htmlCanvas.option(value(entry))
                    .write(entry)
                    ._option();
            }
            htmlCanvas._select()
        ._form()
        ._div()
        .div(id("recipeContent"))._div();
    }
}

Improve selection of the Recipe


package us.thirdmillenium.desktoptrainer;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;

import us.thirdmillenium.desktoptrainer.environment.SinglePlayEnvironment;

import java.util.Random;

public class DesktopTrainer extends ApplicationAdapter {
    // Test Map Index (1 - 5)
    private int TestMapIndex = 3;

    // Environment
    private SinglePlayEnvironment MyEnvironment;

    @Override
    public void create () {
        Random random = new Random();

        this.MyEnvironment = new SinglePlayEnvironment(TrainingParams.PathToBaseNN, random, TestMapIndex);
    }

    @Override
    public void render () {
        this.MyEnvironment.simulate(Gdx.graphics.getDeltaTime());
    }
}

package us.thirdmillenium.desktoptrainer;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;

import us.thirdmillenium.desktoptrainer.environment.Environment;

import java.util.Random;

public class DesktopTrainer extends ApplicationAdapter {
    // Environment
    private Environment MyEnvironment;

    @Override
    public void create () {
        Random random = new Random();

        this.MyEnvironment = new Environment(TrainingParams.PathToBaseNN, random, 5);
    }

    @Override
    public void render () {
        this.MyEnvironment.render(Gdx.graphics.getDeltaTime());
    }
}

Revert "Environment is now an extendible Java class"


/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author 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 fr.pilato.elasticsearch.crawler.fs;

/**
 * Shutdown hook so we make sure we close everything
 */
class FSCrawlerShutdownHook extends Thread implements Runnable {

    private final FsCrawlerImpl fsCrawler;

    public FSCrawlerShutdownHook(FsCrawlerImpl fsCrawler) {
        this.fsCrawler = fsCrawler;
    }

    @Override
    public void run() {
        try {
            fsCrawler.close();
        } catch (InterruptedException ignored) {
        }
    }
}

/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author 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 fr.pilato.elasticsearch.crawler.fs;

/**
 * Shutdown hook so we make sure we close everything
 */
class FSCrawlerShutdownHook extends Thread implements Runnable {

    private final FsCrawlerImpl fsCrawler;

    public FSCrawlerShutdownHook(FsCrawlerImpl fsCrawler) {
        this.fsCrawler = fsCrawler;
    }

    @Override
    public void run() {
        try {
            fsCrawler.close();
        } catch (InterruptedException ignored) {
            Thread.currentThread().interrupt();
        }
    }
}

Fix Sonar errors and warnings


package de.metalmatze.krautreporter.activities;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.widget.ImageView;
import android.widget.TextView;

import com.activeandroid.query.Select;

import java.text.SimpleDateFormat;

import de.metalmatze.krautreporter.R;
import de.metalmatze.krautreporter.models.ArticleModel;

public class ArticleActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_article);
        this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        long id = getIntent().getLongExtra("id", -1);
        ArticleModel model = new Select().from(ArticleModel.class).where("id = ?", id).executeSingle();

        TextView articleTitle = (TextView) findViewById(R.id.article_title);
        TextView articleDate = (TextView) findViewById(R.id.article_date);
        ImageView articleImage = (ImageView) findViewById(R.id.image);
        TextView articleExcerpt = (TextView) findViewById(R.id.article_excerpt);
        TextView articleContent = (TextView) findViewById(R.id.article_content);

        articleTitle.setText(model.title);
        articleDate.setText(new SimpleDateFormat("dd.MM.yyyy").format(model.date.getTime()));
        articleContent.setText(model.content);
    }

}

package de.metalmatze.krautreporter.activities;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.text.Html;
import android.widget.ImageView;
import android.widget.TextView;

import com.activeandroid.query.Select;

import java.text.SimpleDateFormat;

import de.metalmatze.krautreporter.R;
import de.metalmatze.krautreporter.models.ArticleModel;

public class ArticleActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_article);
        this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        long id = getIntent().getLongExtra("id", -1);
        ArticleModel articleModel = new Select().from(ArticleModel.class).where("id = ?", id).executeSingle();

        TextView articleTitle = (TextView) findViewById(R.id.article_title);
        TextView articleDate = (TextView) findViewById(R.id.article_date);
        ImageView articleImage = (ImageView) findViewById(R.id.image);
        TextView articleExcerpt = (TextView) findViewById(R.id.article_excerpt);
        TextView articleContent = (TextView) findViewById(R.id.article_content);

        articleTitle.setText(articleModel.title);
        articleDate.setText(new SimpleDateFormat("dd.MM.yyyy").format(articleModel.date.getTime()));
        articleContent.setText(Html.fromHtml(articleModel.content));
    }

}

Convert HTML content to spanned to use in content TextView


/**
 * Copyright 2013 Mat Booth <mbooth@apache.org>
 */
package com.gpm.calameo;

public class SingleDrm {
  private String ID;
  private String SubscriptionID;
  private String SubscriberLogin;
  private Publication Book;
  private String Extras;

  public SingleDrm() {
  }

  public String getId() {
    return ID;
  }

  public String getSubscriptionId() {
    return SubscriptionID;
  }

  public String getSubscriberLogin() {
    return SubscriberLogin;
  }

  public Publication getBook() {
    return Book;
  }

  public String getExtras() {
    return Extras;
  }

  @Override
  public String toString() {
    return String.format("{ ID: %s, Subscription ID: %s, Subscriber Login: %s, Book: %s, Extras: %s }", getId(),
        getSubscriptionId(), getSubscriberLogin(), getBook(), getExtras());
  }
}

/*
 * Copyright 2013 Mat Booth <mbooth@apache.org>
 *
 * 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.gpm.calameo;

public class SingleDrm {
  private String ID;
  private String SubscriptionID;
  private String SubscriberLogin;
  private Publication Book;
  private String Extras;

  public SingleDrm() {
  }

  public String getId() {
    return ID;
  }

  public String getSubscriptionId() {
    return SubscriptionID;
  }

  public String getSubscriberLogin() {
    return SubscriberLogin;
  }

  public Publication getBook() {
    return Book;
  }

  public String getExtras() {
    return Extras;
  }

  @Override
  public String toString() {
    return String.format("{ ID: %s, Subscription ID: %s, Subscriber Login: %s, Book: %s, Extras: %s }", getId(),
        getSubscriptionId(), getSubscriberLogin(), getBook(), getExtras());
  }
}

Fix licence header in newly added file.


/*
 * Copyright 2020 Global Biodiversity Information Facility (GBIF)
 *
 * 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.gbif.api.util;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

/**
 * Validates that the URI field is absolute, beginning with either http or https.
 * To use, apply to the URI fields intended for validation.
 * The field must be:
 *

 *
A URI object

 *

 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD})
@Constraint(validatedBy = URIValidator.class)
public @interface HttpURI {
  public abstract Class<?>[] groups() default {};
  public abstract Class<? extends Payload>[] payload() default { };
  public abstract String message() default "";
}

/*
 * Copyright 2020 Global Biodiversity Information Facility (GBIF)
 *
 * 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.gbif.api.util;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

/**
 * Validates that the URI field is absolute, beginning with either http or https.
 * To use, apply to the URI fields intended for validation.
 * The field must be:
 *

 *
A URI object

 *

 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD})
@Constraint(validatedBy = URIValidator.class)
public @interface HttpURI {

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

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

  String message() default "Invalid URI";
}

Add default message to URI validator


package com.k13n.lt_codes;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * Unit test for simple App.
 */
public class AppTest
    extends TestCase
{
    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public AppTest( String testName )
    {
        super( testName );
    }

    /**
     * @return the suite of tests being tested
     */
    public static Test suite()
    {
        return new TestSuite( AppTest.class );
    }

    /**
     * Rigourous Test :-)
     */
    public void testApp()
    {
        assertTrue( true );
    }
}

package com.k13n.lt_codes;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import java.io.*;
import com.k13n.lt_codes.*;

/**
 * Unit test for simple App.
 */
public class AppTest
    extends TestCase
{
    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public AppTest( String testName )
    {
        super( testName );
    }

    /**
     * @return the suite of tests being tested
     */
    public static Test suite()
    {
        return new TestSuite( AppTest.class );
    }

    /**
     * Rigourous Test :-)
     */
    public void testApp()
    {
        assertWorksWithPerfectChannel();
        assertTrue( true );
    }

    private void assertWorksWithPerfectChannel() {
      File testFile = new File("text.txt");
      byte[] data = new byte[(int) file.length()];
      DataInputStream s = new DataInputStream(new FileInputStream(testFile));
      s.readFully(data);
      s.close();

      Encoder enc = new Encoder(data, 1000, 0.1);
      Decoder dec = new Decoder(enc.getSeed(), enc.getNPackets());

      enc.encode(new Encoder.Callback(){
        public boolean call(Encoder encoder, int[] neighbours, byte data[]) {
          return !decoder.receive(data, neighbours);
        }
      });

      dec.write(new FileOutputStream("test.txt.out"));

      //assertFilesEqual("text.txt", "text.txt.out")
    }
}

Add a simple test case, does probably not compile.


package com.rllc.spreadsheet;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * Created by Steven McAdams on 3/7/15.
 */

@Configuration
@PropertySource("file:spreadsheet.properties")
public class Config {
}

package com.rllc.spreadsheet;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * Created by Steven McAdams on 3/7/15.
 */

@Configuration
@PropertySource("classpath:spreadsheet.properties")
public class Config {
}

Revert "change to file resource"


package revert.AI;

import revert.Entities.Actor;

public interface EnemyAi {

	/**
	 * AI to be invoked when an actor is told to attack
	 */
	public void attack(Actor a);

	/**
	 * AI to be invoked when an actor enters the enemy's view
	 * @param a
	 */
	public void inView(Actor a);

	/**
	 * AI to be invoked when an actor exits the enemy's view
	 * @param a
	 */
	public void outOfView(Actor a);

	/**
	 * AI definition of how to act with actors when in an aggressive state
	 */
	public void aggress(Actor a);
}

package revert.AI;

import revert.Entities.Actor;

public interface EnemyAi {

	/**
	 * AI to be invoked when an actor is told to attack
	 */
	public void attack(Actor a);

	/**
	 * AI to be invoked when an actor enters the enemy's view
	 * @param a
	 */
	public void inView(Actor a);

	/**
	 * AI to be invoked when an actor exits the enemy's view
	 * @param a
	 */
	public void outOfView(Actor a);

	/**
	 * AI definition of how to act with actors when in an aggressive state
	 */
	public void aggress(Actor a);

	/**
	 * Get the distance that the ai is capable of seeing things
	 * @return
	 */
	public float viewRange();

	/**
	 * Get distance and which the ai is able to follow at while being aggressive after
	 * something enters its range
	 */
	public float aggressRange();
}

Add ranges necessary for AI interaction


package models.relationships;

import play.libs.F.Promise;

import managers.relationships.HasSubstructureRelationshipManager;
import models.nodes.Feature;
import models.nodes.Rule;
import models.nodes.Substructure;

public class HasSubstructureRelationship extends HasRelationship {
    public Feature startNode;
    public Substructure endNode;

    public HasSubstructureRelationship(
        Feature startNode, Substructure endNode) {
        super(startNode, endNode, endNode.rule);
    }

    public static Promise<Boolean> delete(
        Feature startNode, Substructure endNode) {
        return HasSubstructureRelationshipManager.delete(startNode, endNode);
    }

}

package models.relationships;

import play.libs.F.Promise;

import managers.relationships.HasSubstructureRelationshipManager;
import models.nodes.Feature;
import models.nodes.Substructure;

public class HasSubstructureRelationship extends HasRelationship {
    public Feature startNode;
    public Substructure endNode;

    public HasSubstructureRelationship(
        Feature startNode, Substructure endNode) {
        super(startNode, endNode, endNode.rule);
    }

    public static Promise<Boolean> delete(
        Feature startNode, Substructure endNode) {
        return HasSubstructureRelationshipManager.delete(startNode, endNode);
    }

}

Clean up: Remove unused import.


/*
 * Copyright 1999-2004 The Apache Software Foundation.
 *
 * 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.
 */

/* $Id$ */

package org.apache.fop.fo.extensions;

import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;

/**
 * Base class for pdf bookmark extension objects.
 */
public abstract class ExtensionObj extends FObj {

    /**
     * Create a new extension object.
     *
     * @param parent the parent formatting object
     */
    public ExtensionObj(FONode parent) {
        super(parent);
    }
}

/*
 * Copyright 1999-2004 The Apache Software Foundation.
 *
 * 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.
 */

/* $Id$ */

package org.apache.fop.fo.extensions;

import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;

/**
 * Base class for pdf bookmark extension objects.
 */
public abstract class ExtensionObj extends FObj {

    /**
     * Create a new extension object.
     *
     * @param parent the parent formatting object
     */
    public ExtensionObj(FONode parent) {
        super(parent);
    }

    /**
     * @see org.apache.fop.fo.FONode#processNode
     */
    public void processNode(String elementName, Locator locator,
                            Attributes attlist, PropertyList pList)
        throws SAXParseException
    {
        // Empty
    }

    /**
     * Create a default property list for this element.
     */
    protected PropertyList createPropertyList(PropertyList parent,
                FOEventHandler foEventHandler) throws SAXParseException {
        return null;
    }
}

Fix a regression in pdfoutline.fo. Supply empty createPropertyList and processNode methods since the extension elements handles all attributes themself.


package com.ethlo.time;

public class LeapSecondException extends Throwable
{
}

package com.ethlo.time;

/*-
 * #%L
 * Internet Time Utility
 * %%
 * Copyright (C) 2017 - 2019 Morten Haraldsen (ethlo)
 * %%
 * 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.
 * #L%
 */

import java.time.OffsetDateTime;

public class LeapSecondException extends RuntimeException
{
    private final int secondsInMinute;
    private final OffsetDateTime nearestDateTime;

    public LeapSecondException(OffsetDateTime nearestDateTime, int secondsInMinute)
    {
        this.nearestDateTime = nearestDateTime;
        this.secondsInMinute = secondsInMinute;
    }

    public int getSecondsInMinute()
    {
        return secondsInMinute;
    }

    public OffsetDateTime getNearestDateTime()
    {
        return nearestDateTime;
    }
}

Use exception for signaling leap second


/*
 * Created on Mar 30, 2004
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com.cosylab.acs.alarm;

import junit.framework.Test;
import junit.framework.TestSuite;

/**
 * @author kzagar
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class AllTests {

	public static Test suite() {
		TestSuite suite = new TestSuite("Test for com.cosylab.acs.alarm");
		//$JUnit-BEGIN$
		suite.addTest(new TestSuite(AlarmSourceTest.class));
		suite.addTest(new TestSuite(ACSCategoryDAOTest.class));
		suite.addTest(new TestSuite(AlarmListener.class));
		//$JUnit-END$
//		suite.addTest(new TestSuite(AlarmUserTest.class));
//		suite.addTest(new TestSuite(AlarmDefinitionTest.class));
		return suite;
	}
}

/*
 * Created on Mar 30, 2004
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com.cosylab.acs.alarm;

import junit.framework.Test;
import junit.framework.TestSuite;

/**
 * @author kzagar
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class AllTests {

	public static Test suite() {
		TestSuite suite = new TestSuite("Test for com.cosylab.acs.alarm");
		//$JUnit-BEGIN$
		//suite.addTest(new TestSuite(AlarmSourceTest.class));
		suite.addTest(new TestSuite(ACSCategoryDAOTest.class));
		suite.addTest(new TestSuite(AlarmListener.class));
		//$JUnit-END$
//		suite.addTest(new TestSuite(AlarmUserTest.class));
//		suite.addTest(new TestSuite(AlarmDefinitionTest.class));
		return suite;
	}
}

Test category and listener (removed the sources that are tested in their module)


package br.com.bloder.blormlib.validation.validations;

import android.widget.EditText;

import br.com.bloder.blormlib.validation.Validate;
import br.com.bloder.blormlib.validation.Validation;

/**
 * Created by bloder on 05/06/16.
 */
public class Filled extends Validation {

  public EditText editText;

  @Override
  public Validate validate() {
    return new Validate() {
      @Override
      public boolean validate() {
        editText = (EditText) field;
        return !String.valueOf(editText.getText()).trim().isEmpty();
      }
    };
  }
}

package br.com.bloder.blormlib.validation.validations;

import android.widget.EditText;

import br.com.bloder.blormlib.validation.Validate;
import br.com.bloder.blormlib.validation.Validation;

/**
 * Created by bloder on 05/06/16.
 */
public class Filled extends Validation {

  public EditText editText;

  @Override
  public Validate validate() {
    return new Validate() {
      @Override
      public boolean validate() {
        editText = (EditText) field;
        return !String.valueOf(editText.getText()).trim().isEmpty();
      }

      @Override
      public void onError() {
        editText.setError(errorMessage != null && !errorMessage.isEmpty() ? errorMessage : "This field can't be blank");
      }
    };
  }
}

Implement on error funtion in filled validation


package au.com.outware.cavemansample;

import android.content.Context;

import au.com.outware.caveman.data.repository.EnvironmentContentProviderRepository;
import au.com.outware.caveman.domain.repository.EnvironmentRepository;

/**
 * @author Tim Mutton
 * Copyright © 2015 Outware Mobile. All rights reserved.
 */
public class GetEnvironmentProperty {
    private static final String PROVIDER_AUTHORITY = "au.com.outware.caveman.contentprovider";
    private static final String BASE_URL_KEY = "BaseURL";
    private static final String LOGS_ENABLED_KEY = "LogEnabled";
    private static final String TIMEOUT_KEY = "Timeout";

    private static final String DEFAULT_BASE_URL = "http://base.url";
    private static final boolean DEFAULT_LOGS_ENABLED = false;
    private static final int DEFAULT_TIMEOUT = 2000;

    EnvironmentRepository environmentRepository;

    public GetEnvironmentProperty(Context context) {
        environmentRepository = new EnvironmentContentProviderRepository(context, PROVIDER_AUTHORITY);
    }

    public String getBaseUrl() {
        return environmentRepository.getProperty(BASE_URL_KEY, DEFAULT_BASE_URL);
    }

    public boolean isLoggingEnabled() {
        return environmentRepository.getProperty(LOGS_ENABLED_KEY, DEFAULT_LOGS_ENABLED);
    }

    public int getTimeout() {
        return environmentRepository.getProperty(TIMEOUT_KEY, DEFAULT_TIMEOUT);
    }
}

package au.com.outware.cavemansample;

import android.content.Context;
import android.support.annotation.VisibleForTesting;

import au.com.outware.caveman.data.repository.EnvironmentContentProviderRepository;
import au.com.outware.caveman.domain.repository.EnvironmentRepository;

/**
 * @author Tim Mutton
 * Copyright © 2015 Outware Mobile. All rights reserved.
 */
public class GetEnvironmentProperty {
    private static final String PROVIDER_AUTHORITY = "au.com.outware.caveman.contentprovider";
    private static final String BASE_URL_KEY = "BaseURL";
    private static final String LOGS_ENABLED_KEY = "LoggingEnabled";
    private static final String TIMEOUT_KEY = "Timeout";

    private static final String DEFAULT_BASE_URL = "http://base.url";
    private static final boolean DEFAULT_LOGS_ENABLED = false;
    private static final int DEFAULT_TIMEOUT = 2000;

    @VisibleForTesting
    EnvironmentRepository environmentRepository;

    public GetEnvironmentProperty(Context context) {
        environmentRepository = new EnvironmentContentProviderRepository(context, PROVIDER_AUTHORITY);
    }

    public String getBaseUrl() {
        return environmentRepository.getProperty(BASE_URL_KEY, DEFAULT_BASE_URL);
    }

    public boolean isLoggingEnabled() {
        return environmentRepository.getProperty(LOGS_ENABLED_KEY, DEFAULT_LOGS_ENABLED);
    }

    public int getTimeout() {
        return environmentRepository.getProperty(TIMEOUT_KEY, DEFAULT_TIMEOUT);
    }
}

Change key of logging property


package org.cyclops.integrateddynamics.block;

import net.minecraft.block.Block;
import net.minecraft.block.SaplingBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig;
import org.cyclops.integrateddynamics.IntegratedDynamics;
import org.cyclops.integrateddynamics.world.gen.TreeMenril;

/**
 * Config for the Menril Sapling.
 * @author rubensworks
 *
 */
public class BlockMenrilSaplingConfig extends BlockConfig {

    public BlockMenrilSaplingConfig() {
        super(
                IntegratedDynamics._instance,
                "menril_sapling",
                eConfig -> new SaplingBlock(new TreeMenril(), Block.Properties.create(Material.PLANTS)
                        .doesNotBlockMovement()
                        .tickRandomly()
                        .hardnessAndResistance(0)
                        .sound(SoundType.PLANT)),
                getDefaultItemConstructor(IntegratedDynamics._instance)
        );
    }

}

package org.cyclops.integrateddynamics.block;

import net.minecraft.block.Block;
import net.minecraft.block.SaplingBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig;
import org.cyclops.integrateddynamics.IntegratedDynamics;
import org.cyclops.integrateddynamics.world.gen.TreeMenril;

/**
 * Config for the Menril Sapling.
 * @author rubensworks
 *
 */
public class BlockMenrilSaplingConfig extends BlockConfig {

    public BlockMenrilSaplingConfig() {
        super(
                IntegratedDynamics._instance,
                "menril_sapling",
                eConfig -> new SaplingBlock(new TreeMenril(), Block.Properties.create(Material.PLANTS)
                        .doesNotBlockMovement()
                        .tickRandomly()
                        .hardnessAndResistance(0)
                        .sound(SoundType.PLANT)),
                getDefaultItemConstructor(IntegratedDynamics._instance)
        );
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientSetup);
    }

    public void onClientSetup(FMLClientSetupEvent event) {
        RenderTypeLookup.setRenderLayer(getInstance(), RenderType.getCutout());
    }

}

Fix menril sapling having incorrect render layer


/* This file is part of VoltDB.
 * Copyright (C) 2008-2014 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.
 */

package org.voltdb.compiler;

public class dummy_test_underscore {

}

Add License to dummy file used to test underscores.


public class HelloWorld {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("Hello world 1!");
	}
}

public class HelloWorld {

	public static void main(String[] args) {
		System.out.println("Hello world!");
	}
}

Revert hello world message. Remove comment


package me.jaxbot.wear.leafstatus;

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

/**
 * Created by jonathan on 9/21/14.
 */
public class StartAC extends BroadcastReceiver {
    final static String TAG = "StartAC";

    @Override
    public void onReceive(final Context context, Intent intent) {
        Log.i(TAG, "Starting AC...");

        Intent acintent = new Intent(context, StartACService.class);
        context.startService(acintent);
    }
}

package me.jaxbot.wear.leafstatus;

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

/**
 * Created by jonathan on 9/21/14.
 */
public class StartAC extends BroadcastReceiver {
    final static String TAG = "StartAC";

    @Override
    public void onReceive(final Context context, Intent intent) {
        Log.i(TAG, "Starting AC...");

        Intent acintent = new Intent(context, StartACService.class);
        acintent.putExtra("desiredState", intent.getBooleanExtra("desiredState", false));
        context.startService(acintent);
    }
}

Copy desired state into intent


package info.u_team.u_team_test2;

import org.apache.logging.log4j.*;

import info.u_team.u_team_core.util.verify.JarSignVerifier;
import net.minecraftforge.fml.common.Mod;

@Mod(TestMod2.MODID)
public class TestMod2 {

	public static final String MODID = "uteamtest2";
	public static final Logger LOGGER = LogManager.getLogger("UTeamTest2");

	public TestMod2() {
		JarSignVerifier.checkSigned(MODID);

		LOGGER.info("-------------------------------------- LOADING TEST MOD 2 -------------------------------------");
	}
}

package info.u_team.u_team_test2;

import org.apache.logging.log4j.*;

import info.u_team.u_team_core.construct.ConstructManager;
import info.u_team.u_team_core.integration.IntegrationManager;
import info.u_team.u_team_core.util.verify.JarSignVerifier;
import net.minecraftforge.fml.common.Mod;

@Mod(TestMod2.MODID)
public class TestMod2 {

	public static final String MODID = "uteamtest2";
	public static final Logger LOGGER = LogManager.getLogger("UTeamTest2");

	public TestMod2() {
		JarSignVerifier.checkSigned(MODID);

		LOGGER.info("-------------------------------------- LOADING TEST MOD 2 -------------------------------------");

		ConstructManager.constructConstructs(MODID);
		IntegrationManager.constructIntegrations(MODID);
	}
}

Call the construct manager and the integration manager


package android.view;

import java.util.ArrayList;

public class Menu {

	public ArrayList<MenuItem> menuItems = new ArrayList<MenuItem>();

	public void add(int groupId, int itemId, int order, String title) {
		MenuItem item = new MenuItem();
		item.setGroupId(groupId);
		item.setItemId(itemId);
		item.setOrder(order);
		item.setTitle(title);
		menuItems.add(item);
	}

}

package android.view;

import java.util.ArrayList;

public class Menu {

	public ArrayList<MenuItem> menuItems = new ArrayList<MenuItem>();

	public MenuItem add(int groupId, int itemId, int order, String title) {
		MenuItem item = new MenuItem();
		item.setGroupId(groupId);
		item.setItemId(itemId);
		item.setOrder(order);
		item.setTitle(title);
		menuItems.add(item);
        return item;
	}

}

Add must return a menuitem


package models;

import java.util.*;
import javax.persistence.*;

import play.db.ebean.*;
import play.data.format.*;
import play.data.validation.*;

import com.avaje.ebean.*;

/**
 * Computer entity managed by Ebean
 */
@Entity
public class Computer extends Model {

    @Id
    public Long id;

    @Constraints.Required
    public String name;

    @Formats.DateTime(pattern="yyyy-MM-dd")
    public Date introduced;

    @Formats.DateTime(pattern="yyyy-MM-dd")
    public Date discontinued;

    @ManyToOne
    public Company company;

    /**
     * Generic query helper for entity Computer with id Long
     */
    public static Finder<Long,Computer> find = new Finder<Long,Computer>(Long.class, Computer.class);

    /**
     * Return a page of computer
     *
     * @param page Page to display
     * @param pageSize Number of computers per page
     * @param sortBy Computer property used for sorting
     * @param order Sort order (either or asc or desc)
     * @param filter Filter applied on the name column
     */
    public static Page<Computer> page(int page, int pageSize, String sortBy, String order, String filter) {
        return
            find.where()
                .ilike("name", "%" + filter + "%")
                .orderBy(sortBy + " " + order)
                .fetch("company")
                .findPagingList(pageSize)
                .getPage(page);
    }

}

package models;

import java.util.*;
import javax.persistence.*;

import play.db.ebean.*;
import play.data.format.*;
import play.data.validation.*;

import com.avaje.ebean.*;

/**
 * Computer entity managed by Ebean
 */
@Entity
public class Computer extends Model {

    @Id
    public Long id;

    @Constraints.Required
    public String name;

    @Formats.DateTime(pattern="yyyy-MM-dd")
    public Date introduced;

    @Formats.DateTime(pattern="yyyy-MM-dd")
    public Date discontinued;

    @ManyToOne
    public Company company;

    /**
     * Generic query helper for entity Computer with id Long
     */
    public static Finder<Long,Computer> find = new Finder<Long,Computer>(Long.class, Computer.class);

    /**
     * Return a page of computer
     *
     * @param page Page to display
     * @param pageSize Number of computers per page
     * @param sortBy Computer property used for sorting
     * @param order Sort order (either or asc or desc)
     * @param filter Filter applied on the name column
     */
    public static Page<Computer> page(int page, int pageSize, String sortBy, String order, String filter) {
        return
            find.where()
                .ilike("name", "%" + filter + "%")
                .orderBy(sortBy + " " + order)
                .fetch("company")
                .findPagingList(pageSize)
                .setFetchAhead(false)
                .getPage(page);
    }

}

Fix to avoid asynchronous Ebean fetchAhead (automatically fetches the next page)


package crazypants.enderio.enchantment;

import net.minecraft.enchantment.Enchantment;
import crazypants.enderio.Log;
import crazypants.enderio.config.Config;

public class Enchantments {

  private static Enchantments instance;

  public static Enchantments getInstance() {
    if(instance == null) {
      instance = new Enchantments();
      instance.registerEnchantments();
    }
    return instance;
  }

  private EnchantmentSoulBound soulBound;

  private void registerEnchantments() {
    if(Config.enchantmentSoulBoundEnabled) {
      int id = Config.enchantmentSoulBoundId;
      if(id < 0) {
        getEmptyEnchantId();
      }
      if(id < 0) {
        Log.error("Could not find an empty enchantment ID to add enchanments");
        return;
      }
      soulBound = EnchantmentSoulBound.create(id);
    }
  }

  private int getEmptyEnchantId() {
    for (int i = 0; i < Enchantment.enchantmentsList.length; i++) {
      if(Enchantment.enchantmentsList[i] == null) {
        return i;
      }
    }
    return -1;
  }

}

package crazypants.enderio.enchantment;

import net.minecraft.enchantment.Enchantment;
import crazypants.enderio.Log;
import crazypants.enderio.config.Config;

public class Enchantments {

  private static Enchantments instance;

  public static Enchantments getInstance() {
    if(instance == null) {
      instance = new Enchantments();
      instance.registerEnchantments();
    }
    return instance;
  }

  private EnchantmentSoulBound soulBound;

  private void registerEnchantments() {
    if(Config.enchantmentSoulBoundEnabled) {
      int id = Config.enchantmentSoulBoundId;
      if(id < 0) {
        id = getEmptyEnchantId();
      }
      if(id < 0) {
        Log.error("Could not find an empty enchantment ID to add enchanments");
        return;
      }
      soulBound = EnchantmentSoulBound.create(id);
    }
  }

  private int getEmptyEnchantId() {
    for (int i = 0; i < Enchantment.enchantmentsList.length; i++) {
      if(Enchantment.enchantmentsList[i] == null) {
        return i;
      }
    }
    return -1;
  }

}

Fix SoulBound enchant not registering when id set to -1 @CrazyPants wat r u doin


package com.rhomobile.rhodes.webview;

import android.content.Context;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class RhoWebSettingsNew implements RhoWebSettings {

	public WebSettings setWebSettings(WebView w) {
		RhoWebSettingsOld ws = new RhoWebSettingsOld();
		WebSettings webSettings = ws.setWebSettings(w);

		webSettings.setAppCacheEnabled(true);

		webSettings.setDatabaseEnabled(true);
		webSettings.setJavaScriptEnabled(true);

		Context context = w.getContext();
		String databasePath = context.getDir("database", Context.MODE_PRIVATE).getPath();
		webSettings.setDatabasePath(databasePath);

		return webSettings;
	}

}

package com.rhomobile.rhodes.webview;

import android.content.Context;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class RhoWebSettingsNew implements RhoWebSettings {

	public WebSettings setWebSettings(WebView w) {
		RhoWebSettingsOld ws = new RhoWebSettingsOld();
		WebSettings webSettings = ws.setWebSettings(w);

		webSettings.setAppCacheEnabled(true);

		webSettings.setDatabaseEnabled(true);
		webSettings.setJavaScriptEnabled(true);
		webSettings.setDomStorageEnabled(true);

		Context context = w.getContext();
		String databasePath = context.getDir("database", Context.MODE_PRIVATE).getPath();
		webSettings.setDatabasePath(databasePath);

		return webSettings;
	}

}

Fix localStorage access from js.


package org.hibernate.ogm.hiking.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OrderColumn;
import javax.validation.constraints.NotNull;

@Entity
public class Hike {

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long id;

	@NotNull
	public String start;

	@NotNull
	public String destination;

	@ManyToOne
	public Person organizer;

	@ElementCollection
	@OrderColumn(name="order")
	public List<Section> sections = new ArrayList<>();

	Hike() {
	}

	public Hike(String start, String destination) {
		this.start = start;
		this.destination = destination;
	}
}

package org.hibernate.ogm.hiking.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OrderColumn;
import javax.validation.constraints.NotNull;

@Entity
public class Hike {

	@Id
	@GeneratedValue(strategy=GenerationType.TABLE)
	public long id;

	@NotNull
	public String start;

	@NotNull
	public String destination;

	@ManyToOne
	public Person organizer;

	@ElementCollection
	@OrderColumn(name="order")
	public List<Section> sections = new ArrayList<>();

	Hike() {
	}

	public Hike(String start, String destination) {
		this.start = start;
		this.destination = destination;
	}
}

Move to explicit generator to avoid warning


package com.kickstarter.libs;

import android.os.Bundle;

import rx.subjects.PublishSubject;

public class Presenter<ViewType> {
  protected final PublishSubject<ViewType> viewSubject = PublishSubject.create();

  protected void onCreate(Bundle savedInstanceState) {
    viewSubject.onNext(null);
  }

  protected void onResume(ViewType view) {
    viewSubject.onNext(view);
  }

  protected void onPause() {
    viewSubject.onNext(null);
  }

  protected void onDestroy() {
    viewSubject.onCompleted();
  }

  public void save(Bundle state) {
    // TODO
  }

}

package com.kickstarter.libs;

import android.os.Bundle;

import java.util.ArrayList;
import java.util.List;

import rx.Subscription;
import rx.subjects.PublishSubject;

public class Presenter<ViewType> {
  protected final PublishSubject<ViewType> viewSubject = PublishSubject.create();
  protected final List<Subscription> subscriptions = new ArrayList<>();

  protected void onCreate(Bundle savedInstanceState) {
    viewSubject.onNext(null);
  }

  protected void onResume(ViewType view) {
    viewSubject.onNext(view);
  }

  protected void onPause() {
    viewSubject.onNext(null);
  }

  protected void onDestroy() {
    for (Subscription subscription : subscriptions) {
      subscription.unsubscribe();
    }

    viewSubject.onCompleted();
  }

  public void save(Bundle state) {
    // TODO
  }
}

Add subscriptions, unsubscribe to all when presenter is destroyed


package com.bugsnag.serialization;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.io.OutputStream;

public class Serializer {
    private ObjectMapper mapper = new ObjectMapper();

    /**
     * Constructor.
     */
    public Serializer() {
        mapper
            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
            .setVisibility(
                mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE));
    }

    /**
     * Write the object to the stream.
     *
     * @param stream the stream to write the object to.
     * @param object the object to write to the stream.
     * @throws SerializationException the object could not be serialized.
     */
    public void writeToStream(OutputStream stream, Object object) throws SerializationException {
        try {
            mapper.writeValue(stream, object);
        } catch (IOException ex) {
            throw new SerializationException("Exception during serialization", ex);
        }
    }
}

package com.bugsnag.serialization;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.io.OutputStream;

public class Serializer {
    private ObjectMapper mapper = new ObjectMapper();

    /**
     * Constructor.
     */
    @SuppressWarnings("deprecation") // Use deprecated method to ensure we don't break with older versions of jackson
    public Serializer() {
        mapper
            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
            .setVisibilityChecker(
                mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE));
    }

    /**
     * Write the object to the stream.
     *
     * @param stream the stream to write the object to.
     * @param object the object to write to the stream.
     * @throws SerializationException the object could not be serialized.
     */
    public void writeToStream(OutputStream stream, Object object) throws SerializationException {
        try {
            mapper.writeValue(stream, object);
        } catch (IOException ex) {
            throw new SerializationException("Exception during serialization", ex);
        }
    }
}


/*
 * $Id: AltRepTest.java [23-Apr-2004]
 *
 * Copyright (c) 2004, Ben Fortuna All rights reserved.
 */
package net.fortuna.ical4j.model.parameter;

import java.net.URI;
import java.net.URISyntaxException;

import net.fortuna.ical4j.model.Parameter;
import net.fortuna.ical4j.model.ParameterFactoryImpl;

import junit.framework.TestCase;

/**
 * Test case for AltRep.
 * @author benfortuna
 */
public class AltRepTest extends TestCase {

    /*
     * Class to test for void AltRep(String)
     */
    public void testAltRepString() throws URISyntaxException {

        try {
            new AltRep("::...invalid...");

            fail("URISyntaxException not thrown!");
        }
        catch (URISyntaxException use) {
            // test success.
        }

        AltRep ar = (AltRep) ParameterFactoryImpl.getInstance().createParameter(Parameter.ALTREP, "mailto:valid@test.com");

        assertNotNull(ar.getUri());
    }

    /*
     * Class to test for void AltRep(URI)
     */
    public void testAltRepURI() throws URISyntaxException {

        AltRep ar = new AltRep(new URI("mailto:valid@test.com"));

        assertNotNull(ar.getUri());
    }

}

/*
 * $Id: AltRepTest.java [23-Apr-2004]
 *
 * Copyright (c) 2004, Ben Fortuna All rights reserved.
 */
package net.fortuna.ical4j.model.parameter;

import java.net.URI;
import java.net.URISyntaxException;

import net.fortuna.ical4j.model.Parameter;
import net.fortuna.ical4j.model.ParameterFactoryImpl;

import junit.framework.TestCase;

/**
 * Test case for AltRep.
 * @author benfortuna
 */
public class AltRepTest extends TestCase {

    /*
     * Class to test for void AltRep(String)
     */
    public void testAltRepString() throws URISyntaxException {

        try {
            new AltRep("<mailto:../:...invalid...>");

            fail("URISyntaxException not thrown!");
        }
        catch (URISyntaxException use) {
            // test success.
        }

        AltRep ar = (AltRep) ParameterFactoryImpl.getInstance().createParameter(Parameter.ALTREP, "mailto:valid@test.com");

        assertNotNull(ar.getUri());
    }

    /*
     * Class to test for void AltRep(URI)
     */
    public void testAltRepURI() throws URISyntaxException {

        AltRep ar = new AltRep(new URI("mailto:valid@test.com"));

        assertNotNull(ar.getUri());
    }

}

Update invalid URI to correctly throw exception


package org.jabref;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Catch and log any unhandled exceptions.
 */
public class FallbackExceptionHandler implements Thread.UncaughtExceptionHandler {

    private static final Logger LOGGER = LoggerFactory.getLogger(FallbackExceptionHandler.class);

    public static void installExceptionHandler() {
        Thread.setDefaultUncaughtExceptionHandler(new FallbackExceptionHandler());
    }

    @Override
    public void uncaughtException(Thread thread, Throwable exception) {
        LOGGER.error("Uncaught exception occurred in " + thread, exception);
        JabRefGUI.getMainFrame()
                 .getDialogService()
                 .showErrorDialogAndWait(
                                         exception.getLocalizedMessage(), exception);
    }
}

package org.jabref;

import org.jabref.gui.util.DefaultTaskExecutor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Catch and log any unhandled exceptions.
 */
public class FallbackExceptionHandler implements Thread.UncaughtExceptionHandler {

    private static final Logger LOGGER = LoggerFactory.getLogger(FallbackExceptionHandler.class);

    public static void installExceptionHandler() {
        Thread.setDefaultUncaughtExceptionHandler(new FallbackExceptionHandler());
    }

    @Override
    public void uncaughtException(Thread thread, Throwable exception) {
        LOGGER.error("Uncaught exception occurred in " + thread, exception);

        DefaultTaskExecutor.runInJavaFXThread(() ->
                JabRefGUI.getMainFrame()
                         .getDialogService()
                         .showErrorDialogAndWait("Uncaught exception occurred in " + thread, exception)
        );
    }
}

Fix not on FX thread exception


/**
 * This test simply overflows the stack through recursion.
 *
 * @author Elvis Stansvik <elvstone@gmail.com>
 */
class StackOverflow {
    public static void main(String[] args) {
        Overflower o;
        o = new Overflower();
        o.overflow();
    }
}

class Overflower {
    public int overflow() {
        int a;
        int b;
        int c;
        return this.overflow();
    }
}

/**
 * This test simply overflows the stack through recursion.
 *
 * @author Elvis Stansvik <elvstone@gmail.com>
 */
class StackOverflow {
    public static void main(String[] args) {
        Overflower o;
        int r;
        o = new Overflower();
        r = o.overflow();
    }
}

class Overflower {
    public int overflow() {
        int a;
        int b;
        int c;
        return this.overflow();
    }
}

Make test case MiniJava (bah!).


// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; -*-
// vim: et ts=4 sts=4 sw=4 syntax=java
package com.aragaer.jtt.core;

import static org.junit.Assert.*;

import org.junit.Test;

public class JdnTest {

    @Test public void testTimestampToJdn() {
        assertEquals(Jdn.fromTimestamp(1486502734000L), 2457792);
    }

    @Test public void testJdnToTimestamp() {
        assertEquals(Jdn.toTimestamp(2457792L), 1486468800000L);
    }
}

// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; -*-
// vim: et ts=4 sts=4 sw=4 syntax=java
package com.aragaer.jtt.core;

import static org.junit.Assert.*;

import org.junit.Test;

public class JdnTest {

    @Test public void testHaveToTestConstructor() {
        Jdn jdn = new Jdn(); // For now this serves only to fix coverage report
    }

    @Test public void testTimestampToJdn() {
        assertEquals(Jdn.fromTimestamp(1486502734000L), 2457792);
    }

    @Test public void testJdnToTimestamp() {
        assertEquals(Jdn.toTimestamp(2457792L), 1486468800000L);
    }
}

Fix Jdn class coverage report


package com.nirima.jenkins.plugins.docker.utils;

import com.github.dockerjava.api.model.ResponseItem;
import hudson.model.BuildListener;

/**
 * @author Kanstantsin Shautsou
 */
public class LogUtils {
    private LogUtils() {
    }

    public static void printResponseItemToListener(BuildListener listener, ResponseItem item) {
        if (item.getStatus() != null) {
            if (item.getError() != null) {
                listener.error(item.getError());
            }

            final StringBuilder stringBuffer = new StringBuilder();

            if (item.getId() != null) {
                stringBuffer.append(item.getId()).append(": "); // Doesn't exist before "Digest"
            }

            stringBuffer.append(item.getStatus());

            if (item.getProgress() != null) {
                stringBuffer.append(" ").append(item.getProgress());
            }

            listener.getLogger().println(stringBuffer.toString());
        }
    }
}

package com.nirima.jenkins.plugins.docker.utils;

import com.github.dockerjava.api.model.ResponseItem;
import hudson.model.BuildListener;
import hudson.model.TaskListener;

/**
 * @author Kanstantsin Shautsou
 */
public class LogUtils {
    private LogUtils() {
    }

    public static void printResponseItemToListener(TaskListener listener, ResponseItem item) {
        if (item.getStatus() != null) {
            if (item.getError() != null) {
                listener.error(item.getError());
            }

            final StringBuilder stringBuffer = new StringBuilder();

            if (item.getId() != null) {
                stringBuffer.append(item.getId()).append(": "); // Doesn't exist before "Digest"
            }

            stringBuffer.append(item.getStatus());

            if (item.getProgress() != null) {
                stringBuffer.append(" ").append(item.getProgress());
            }

            listener.getLogger().println(stringBuffer.toString());
        }
    }
}

Make logging take superclass so not tied to Builds only.