package jcrib;

public class Score {

    public enum Type { Fifteen, ThirtyOne, Pair, Run, Flush, Nobs, Heels, Go };

    private Type type;
    private Card[] cards;
    private int points;

    public Score(Type type, Card[] cards, int points) {
        this.type = type;
        this.cards = cards;
        this.points = points;
    }

    public Card[] getCards() {
        return cards;
    }

    public int getPoints() {
        return points;
    }

    @Override
    public String toString() {
        String str = "";
        for (Card card : cards) {
            str += card + " ";
        }
        return type + " ( " + str + ") = " + points;
    }
}

package jcrib;

import jcrib.cards.Card;

public class Score {

    public enum Type { Fifteen, ThirtyOne, Pair, Run, Flush, Nobs, Heels, Go };

    private Type type;
    private Card[] cards;
    private int points;

    public Score(Type type, Card[] cards, int points) {
        this.type = type;
        this.cards = cards;
        this.points = points;
    }

    public Card[] getCards() {
        return cards;
    }

    public int getPoints() {
        return points;
    }

    @Override
    public String toString() {
        String str = "";
        for (Card card : cards) {
            str += card + " ";
        }
        return type + " ( " + str + ") = " + points;
    }
}

Update for cards package refactoring


package adapter;

import static adapter.adapter2.Level.ERROR;

public interface adapter2 {
  public interface Logger {
    public void log(String message);
  }

  public enum Level { WARNING, ERROR }
  public interface Logger2 {
    public void log(Level level, String message);

    public default Logger error() {
      return msg -> log(ERROR, msg);
    }
  }

  public static void main(String[] args) {
    Logger2 logger2 = (level, msg) -> System.out.println(level + " " + msg);
    logger2.log(ERROR, "abort abort !");

    logger2.error().log("abort abort !");
  }
}

package adapter;

import static adapter.adapter2.Level.ERROR;

public interface adapter2 {
  public interface Logger {
    public void log(String message);
  }

  public enum Level { WARNING, ERROR }
  public interface Logger2 {
    public void log(Level level, String message);

    public default Logger level(Level level) {
      return msg -> log(level, msg);
    }
  }

  public static void main(String[] args) {
    Logger2 logger2 = (level, msg) -> System.out.println(level + " " + msg);
    logger2.log(ERROR, "abort abort !");

    logger2.level(ERROR).log("abort abort !");
  }
}

Make the partial application more explicit


package nom.bdezonia.zorbage.algorithm; class TestInvFFT {}

/*
 * Zorbage: an algebraic data hierarchy for use in numeric processing.
 *
 * Copyright (C) 2016-2018 Barry DeZonia
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package nom.bdezonia.zorbage.algorithm;

/**
 *
 * @author Barry DeZonia
 *
 */
public class TestInvFFT {

	// The InvFFT class tested in TestFFT. Nothing to do here.

}

Document the testing of the InvFFT algorithm


package com.cgi.eoss.ftep.search;

import com.cgi.eoss.ftep.catalogue.CatalogueConfig;
import com.cgi.eoss.ftep.persistence.PersistenceConfig;
import com.cgi.eoss.ftep.search.api.SearchFacade;
import com.cgi.eoss.ftep.search.api.SearchProvider;
import okhttp3.OkHttpClient;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.Collection;

@Configuration
@Import({
        PropertyPlaceholderAutoConfiguration.class,

        CatalogueConfig.class,
        PersistenceConfig.class
})
@ComponentScan(basePackageClasses = SearchConfig.class)
public class SearchConfig {

    @Bean
    public SearchFacade searchFacade(Collection<SearchProvider> searchProviders) {
        return new SearchFacade(searchProviders);
    }

    @Bean
    public OkHttpClient httpClient() {
        return new OkHttpClient.Builder()
                .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.logica.com", 80)))
                .build();
    }

}

package com.cgi.eoss.ftep.search;

import com.cgi.eoss.ftep.catalogue.CatalogueConfig;
import com.cgi.eoss.ftep.persistence.PersistenceConfig;
import com.cgi.eoss.ftep.search.api.SearchFacade;
import com.cgi.eoss.ftep.search.api.SearchProvider;
import okhttp3.OkHttpClient;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import java.util.Collection;

@Configuration
@Import({
        PropertyPlaceholderAutoConfiguration.class,

        CatalogueConfig.class,
        PersistenceConfig.class
})
@ComponentScan(basePackageClasses = SearchConfig.class)
public class SearchConfig {

    @Bean
    public SearchFacade searchFacade(Collection<SearchProvider> searchProviders) {
        return new SearchFacade(searchProviders);
    }

    @Bean
    public OkHttpClient httpClient() {
        return new OkHttpClient.Builder().build();
    }

}

Remove invalid proxy config from search facade


package retromock.matchers;

import org.hamcrest.Description;
import org.hamcrest.TypeSafeDiagnosingMatcher;

import java.util.regex.Pattern;

public class IsRegex extends TypeSafeDiagnosingMatcher<String> {

    private final Pattern pattern;

    public static IsRegex matchesRegex(String regex) {
        return new IsRegex(Pattern.compile(regex));
    }

    public IsRegex(Pattern pattern) {
        this.pattern = pattern;
    }

    @Override
    protected boolean matchesSafely(String item, Description mismatchDescription) {
        return pattern.matcher(item).matches();
    }

    @Override
    public void describeTo(Description description) {
        description
                .appendText("a string matching the pattern '")
                .appendValue(pattern)
                .appendText("'");
    }
}

package retromock.matchers;

import org.hamcrest.Description;
import org.hamcrest.TypeSafeDiagnosingMatcher;

import java.util.regex.Pattern;

public class IsRegex extends TypeSafeDiagnosingMatcher<String> {

    private final Pattern pattern;

    public static IsRegex matchesRegex(String regex) {
        return new IsRegex(Pattern.compile(regex));
    }

    public IsRegex(Pattern pattern) {
        this.pattern = pattern;
    }

    @Override
    protected boolean matchesSafely(String item, Description mismatchDescription) {
        final boolean matches = pattern.matcher(item).matches();
        if (!matches) {
            mismatchDescription
                    .appendText("Item ")
                    .appendValue(item)
                    .appendText(" did not match pattern ")
                    .appendValue(pattern);
        }
        return matches;
    }

    @Override
    public void describeTo(Description description) {
        description
                .appendText("a string matching the pattern '")
                .appendValue(pattern)
                .appendText("'");
    }
}

Add describing text to mismatchDescription in case on mismatch


package com.crawljax.util;

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

import java.io.File;

import org.junit.Ignore;

public class PrettyHTMLTest {

	private static final String TESTFILE = "src/test/java/com/crawljax/util/tuduDombefore.html";
	private static final String CONTROLFILE =
	        "src/test/java/com/crawljax/util/tuduDombefore.html.tidy";

	@Ignore
	public void prettifyHTML() {
		String testdom = Helper.getContent(new File(TESTFILE));
		String controldom = Helper.getContent(new File(CONTROLFILE));

		assertNotNull("File should be read", testdom);
		assertNotNull("File should be read", controldom);

		testdom = PrettyHTML.prettyHTML(testdom);

		assertEquals(controldom, testdom);
	}
}

package com.crawljax.util;

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

import java.io.File;

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

public class PrettyHTMLTest {

	private static final String TESTFILE = "src/test/java/com/crawljax/util/tuduDombefore.html";
	private static final String CONTROLFILE =
	        "src/test/java/com/crawljax/util/tuduDombefore.html.tidy";

	@Ignore
	@Test
	public void prettifyHTML() {
		String testdom = Helper.getContent(new File(TESTFILE));
		String controldom = Helper.getContent(new File(CONTROLFILE));

		assertNotNull("File should be read", testdom);
		assertNotNull("File should be read", controldom);

		testdom = PrettyHTML.prettyHTML(testdom);

		assertEquals(controldom, testdom);
	}
}

Add test annotation again, ignore overrides this.


package asteroid.nodes;

import asteroid.A;

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

import org.codehaus.groovy.ast.Parameter;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.MethodNode;
import org.codehaus.groovy.ast.stmt.Statement;

/**
 * Builder to create instance of type {@link MethodNode}
 *
 * @since 0.1.0
 */
public class MethodNodeBuilder {

    private final String name;
    private int modifiers;
    private Statement code;
    private ClassNode returnType;
    private Parameter[] parameters;
    private ClassNode[] exceptions;

    private MethodNodeBuilder(String name) {
        this.name = name;
    }

    public static MethodNodeBuilder method(String name) {
        return new MethodNodeBuilder(name);
    }

    public MethodNodeBuilder returnType(Class returnType) {
        this.returnType = A.NODES.clazz(returnType).build();
        return this;
    }

    public MethodNodeBuilder modifiers(int modifiers) {
        this.modifiers = modifiers;
        return this;
    }

    public MethodNodeBuilder parameters(Parameter... parameters) {
        this.parameters = parameters;
        return this;
    }

    public MethodNodeBuilder exceptions(ClassNode... exceptions) {
        this.exceptions = exceptions;
        return this;
    }

    public MethodNodeBuilder code(Statement code) {
        this.code = code;
        return this;
    }

    public MethodNode build() {
        MethodNode methodNode =
            new MethodNode(name,
                           modifiers,
                           returnType,
                           parameters,
                           exceptions,
                           code);

        return methodNode;
    }

}

package asteroid.nodes;

import asteroid.A;

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

import org.codehaus.groovy.ast.Parameter;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.MethodNode;
import org.codehaus.groovy.ast.stmt.Statement;

/**
 * Builder to create instance of type {@link MethodNode}
 *
 * @since 0.1.0
 */
public class MethodNodeBuilder {

    private final String name;
    private int modifiers;
    private Statement code;
    private ClassNode returnType;
    private Parameter[] parameters = new Parameter[0];
    private ClassNode[] exceptions = new ClassNode[0];

    private MethodNodeBuilder(String name) {
        this.name = name;
    }

    public static MethodNodeBuilder method(String name) {
        return new MethodNodeBuilder(name);
    }

    public MethodNodeBuilder returnType(Class returnType) {
        this.returnType = A.NODES.clazz(returnType).build();
        return this;
    }

    public MethodNodeBuilder modifiers(int modifiers) {
        this.modifiers = modifiers;
        return this;
    }

    public MethodNodeBuilder parameters(Parameter... parameters) {
        this.parameters = parameters;
        return this;
    }

    public MethodNodeBuilder exceptions(ClassNode... exceptions) {
        this.exceptions = exceptions;
        return this;
    }

    public MethodNodeBuilder code(Statement code) {
        this.code = code;
        return this;
    }

    public MethodNode build() {
        MethodNode methodNode =
            new MethodNode(name,
                           modifiers,
                           returnType,
                           parameters,
                           exceptions,
                           code);

        return methodNode;
    }

}

Fix NPE when no adding parameters or exceptions


package mnm.mods.tabbychat.gui;

import mnm.mods.tabbychat.core.GuiNewChatTC;
import mnm.mods.util.gui.GuiComponent;
import net.minecraft.client.gui.Gui;

public class Scrollbar extends GuiComponent {

    private ChatArea chat;

    public Scrollbar(ChatArea chat) {
        this.chat = chat;
    }

    @Override
    public void drawComponent(int mouseX, int mouseY) {
        if (GuiNewChatTC.getInstance().getChatOpen()) {
            int scroll = chat.getScrollPos();
            int max = chat.getBounds().height;
            int lines = max / mc.fontRendererObj.FONT_HEIGHT;
            int total = chat.getChat(false).size();
            if (total < lines) {
                return;
            }
            total -= lines;
            int size = 25;
            float perc = Math.abs((float) scroll / (float) total - 1) * Math.abs((float) size / (float) max - 1);
            int pos = (int) (perc * max);

            Gui.drawRect(0, pos, 1, pos + size, -1);
        }
    }

}

package mnm.mods.tabbychat.gui;

import mnm.mods.tabbychat.core.GuiNewChatTC;
import mnm.mods.util.gui.GuiComponent;
import net.minecraft.client.gui.Gui;

public class Scrollbar extends GuiComponent {

    private ChatArea chat;

    public Scrollbar(ChatArea chat) {
        this.chat = chat;
    }

    @Override
    public void drawComponent(int mouseX, int mouseY) {
        if (GuiNewChatTC.getInstance().getChatOpen()) {
            int scroll = chat.getScrollPos();
            int max = chat.getBounds().height;
            int lines = max / mc.fontRendererObj.FONT_HEIGHT;
            int total = chat.getChat(false).size();
            if (total <= lines) {
                return;
            }
            total -= lines;
            int size = Math.max(max / total, 10);
            float perc = Math.abs((float) scroll / (float) total - 1) * Math.abs((float) size / (float) max - 1);
            int pos = (int) (perc * max);

            Gui.drawRect(0, pos, 1, pos + size, -1);
        }
    }

}

Make scrollbar size inversely relative to chat size.


package code.donbonifacio.saft;

import junit.framework.TestCase;

/**
 * Tests for the Result class
 */
public class ResultTest extends TestCase {

    /**
     * Tests the Result.success singleton
     */
    public void testSuccessSingleton() {
        Result r1 = Result.success();
        assertTrue(r1.isSucceeded());
        assertFalse(r1.isFailed());

        Result r2 = Result.success();
        assertTrue(r2.isSucceeded());
        assertFalse(r2.isFailed());

        assertTrue(r1 == r2);
    }

    /**
     * Tests a failed result via exception
     */
    public void testResultException() {
        Exception ex = new RuntimeException();
        Result result = Result.exception(ex);
        assertFalse(result.isSucceeded());
        assertTrue(result.isException());
    }
}

package code.donbonifacio.saft;

import junit.framework.TestCase;

import java.util.Arrays;

/**
 * Tests for the Result class
 */
public class ResultTest extends TestCase {

    /**
     * Tests the Result.success singleton
     */
    public void testSuccessSingleton() {
        Result r1 = Result.success();
        assertTrue(r1.isSucceeded());
        assertFalse(r1.isFailed());

        Result r2 = Result.success();
        assertTrue(r2.isSucceeded());
        assertFalse(r2.isFailed());

        assertTrue(r1 == r2);
    }

    /**
     * Tests a failed result via exception
     */
    public void testResultException() {
        Exception ex = new RuntimeException();
        Result result = Result.exception(ex);
        assertFalse(result.isSucceeded());
        assertTrue(result.isException());
    }

    /**
     * Test toString generation
     */
    public void testToString() {
        Result r1 = Result.failure("Test1");
        Result r2 = Result.failure("Test2");
        Result r3 = Result.fromResults(Arrays.asList(r1, r2));

        assertEquals("Result{succeeded=false, reason='From list of results', results=[Result{succeeded=false, reason='Test1'}, Result{succeeded=false, reason='Test2'}, ]}", r3.toString());
    }

    /**
     * If fromResults gets a collection with only one result, return
     * that result
     */
    public void testFromResultsAsOne() {
        Result r1 = Result.success();
        Result r2 = Result.fromResults(r1.asList());

        assertTrue(r1 == r2);

    }
}

Add more tests to Result


/**
 * Copyright 2014 Google Inc. All Rights Reserved.
 */
package com.google.appengine.gcloudapp;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

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

/**
 * Starts the Gcloud App Engine development server and does not wait.
 *
 * @author Ludo
 * @goal run_start
 * @execute phase="validate"
 * @threadSafe false
 */
public class GcloudAppAsyncStart extends GCloudAppRun {

  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {
    getLog().info("");
    getLog().info("Gcloud SDK - Starting the Development Server");
    getLog().info("");

    if(application_directory == null) {
      application_directory = maven_project.getBuild().getDirectory() + "/" + maven_project.getBuild().getFinalName();
    }

    File appDirFile = new File(application_directory);

    if(!appDirFile.exists()) {
      throw new MojoExecutionException("The application directory does not exist : " + application_directory);
    }

    if(!appDirFile.isDirectory()) {
      throw new MojoExecutionException("The application directory is not a directory : " + application_directory);
    }

    ArrayList<String> devAppServerCommand = getCommand(application_directory);

    startCommand(appDirFile, devAppServerCommand, WaitDirective.WAIT_SERVER_STARTED);
  }

}

/**
 * Copyright 2014 Google Inc. All Rights Reserved.
 */
package com.google.appengine.gcloudapp;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

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

/**
 * Starts the Gcloud App Engine development server and does not wait.
 *
 * @author Ludo
 * @goal run_start
 * @execute phase="package"
 * @threadSafe false
 */
public class GcloudAppAsyncStart extends GCloudAppRun {

  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {
    getLog().info("");
    getLog().info("Gcloud SDK - Starting the Development Server");
    getLog().info("");

    if(application_directory == null) {
      application_directory = maven_project.getBuild().getDirectory() + "/" + maven_project.getBuild().getFinalName();
    }

    File appDirFile = new File(application_directory);

    if(!appDirFile.exists()) {
      throw new MojoExecutionException("The application directory does not exist : " + application_directory);
    }

    if(!appDirFile.isDirectory()) {
      throw new MojoExecutionException("The application directory is not a directory : " + application_directory);
    }

    ArrayList<String> devAppServerCommand = getCommand(application_directory);

    startCommand(appDirFile, devAppServerCommand, WaitDirective.WAIT_SERVER_STARTED);
  }

}

Make the run_start goal build the project first.


/*
 * Copyright (C) 2014 Pedro Vicente Gómez Sánchez.
 *
 * 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.github.pedrovgs.problem68;

/**
 * Given a positive int passed as parameter, can you write a method to return true if the number is
 * even or false if the number is odd? The only constraint you have is: you can't use this
 * operator: %.
 *
 * @author Pedro Vicente Gómez Sánchez.
 */
public class IsEven {

}

/*
 * Copyright (C) 2014 Pedro Vicente Gómez Sánchez.
 *
 * 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.github.pedrovgs.problem68;

/**
 * Given a positive int passed as parameter, can you write a method to return true if the number is
 * even or false if the number is odd? The only constraint you have is: you can't use this
 * operator: %.
 *
 * @author Pedro Vicente Gómez Sánchez.
 */
public class IsEven {

  /**
   * Easy algorithm based on "and" binary operator and the simplest mask you are going to see, the
   * number 1. In this method we are going to apply one mask with just one one inside and if the
   * result is different of 1 we will return true. This algorithm is possible because every binary
   * number with one one in the position zero is going to be odd. Review how to calculate an
   * integer
   * from a binary number if you don't understand how it works.
   */
  public boolean check(int n) {
    return (n & 1) != 1;
  }
}

Add solution to problem 68


package info.u_team.u_team_core.block;

import info.u_team.u_team_core.api.registry.IBlockItemProvider;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;

public class UBlock extends Block implements IBlockItemProvider {

	protected final BlockItem blockItem;

	public UBlock(Properties properties) {
		this(null, properties);
	}

	public UBlock(CreativeModeTab group, Properties properties) {
		this(group, properties, null);
	}

	public UBlock(Properties properties, Item.Properties blockItemProperties) {
		this(null, properties, blockItemProperties);
	}

	public UBlock(CreativeModeTab group, Properties properties, Item.Properties blockItemProperties) {
		super(properties);
		blockItem = createBlockItem(blockItemProperties == null ? new Item.Properties().tab(group) : group == null ? blockItemProperties : blockItemProperties.tab(group));
	}

	protected BlockItem createBlockItem(Item.Properties blockItemProperties) {
		return new BlockItem(this, blockItemProperties);
	}

	@Override
	public BlockItem getBlockItem() {
		return blockItem;
	}
}

package info.u_team.u_team_core.block;

import info.u_team.u_team_core.api.registry.IBlockItemProvider;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;

public class UBlock extends Block implements IBlockItemProvider {

	protected final BlockItem blockItem;

	public UBlock(Properties properties) {
		this(null, properties);
	}

	public UBlock(CreativeModeTab creativeTab, Properties properties) {
		this(creativeTab, properties, null);
	}

	public UBlock(Properties properties, Item.Properties blockItemProperties) {
		this(null, properties, blockItemProperties);
	}

	public UBlock(CreativeModeTab creativeTab, Properties properties, Item.Properties blockItemProperties) {
		super(properties);
		blockItem = createBlockItem(blockItemProperties == null ? new Item.Properties().tab(creativeTab) : creativeTab == null ? blockItemProperties : blockItemProperties.tab(creativeTab));
	}

	protected BlockItem createBlockItem(Item.Properties blockItemProperties) {
		return new BlockItem(this, blockItemProperties);
	}

	@Override
	public BlockItem getBlockItem() {
		return blockItem;
	}
}

Rename group variable in block to match the official name


package com.proofpoint.log;

import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.logging.Handler;
import java.util.logging.LogRecord;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.logging.ErrorManager.CLOSE_FAILURE;
import static java.util.logging.ErrorManager.FLUSH_FAILURE;
import static java.util.logging.ErrorManager.FORMAT_FAILURE;
import static java.util.logging.ErrorManager.WRITE_FAILURE;

final class OutputStreamHandler
        extends Handler
{
    private final Writer writer;

    public OutputStreamHandler(OutputStream out)
    {
        writer = new OutputStreamWriter(out, UTF_8);
        setFormatter(new StaticFormatter());
    }

    @Override
    public void publish(LogRecord record)
    {
        if (!isLoggable(record)) {
            return;
        }

        String message;
        try {
            message = getFormatter().format(record);
        }
        catch (Exception e) {
            reportError(null, e, FORMAT_FAILURE);
            return;
        }

        try {
            writer.write(message);
        }
        catch (Exception e) {
            reportError(null, e, WRITE_FAILURE);
        }
    }

    @Override
    public void flush()
    {
        try {
            writer.flush();
        }
        catch (Exception e) {
            reportError(null, e, FLUSH_FAILURE);
        }
    }

    @Override
    public void close()
    {
        try {
            writer.flush();
        }
        catch (Exception e) {
            reportError(null, e, CLOSE_FAILURE);
        }
    }
}

package com.proofpoint.log;

import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Handler;
import java.util.logging.LogRecord;

import static java.nio.charset.StandardCharsets.UTF_8;

final class OutputStreamHandler
        extends Handler
{
    private final StaticFormatter formatter = new StaticFormatter();
    private final AtomicBoolean reported = new AtomicBoolean();
    private final Writer writer;

    public OutputStreamHandler(OutputStream out)
    {
        writer = new OutputStreamWriter(out, UTF_8);
    }

    @Override
    public void publish(LogRecord record)
    {
        if (!isLoggable(record)) {
            return;
        }

        try {
            writer.write(formatter.format(record));
            writer.flush();
        }
        catch (Exception e) {
            // try to report the first error
            if (!reported.getAndSet(true)) {
                PrintWriter error = new PrintWriter(writer);
                error.print("LOGGING FAILED: ");
                e.printStackTrace(error);
                error.flush();
            }
        }
    }

    @Override
    public void flush() {}

    @Override
    public void close() {}
}

Add flushing for console logging


package edu.northwestern.bioinformatics.studycalendar.restlets;

import edu.northwestern.bioinformatics.studycalendar.dao.StudyDao;
import edu.northwestern.bioinformatics.studycalendar.domain.Study;
import edu.northwestern.bioinformatics.studycalendar.domain.Role;
import edu.northwestern.bioinformatics.studycalendar.xml.writers.StudyXmlSerializer;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.data.Method;
import org.restlet.Context;
import org.springframework.beans.factory.annotation.Required;

/**
 * Resource representing a study and its planned calendar, including all amendments.
 *
 * @author Rhett Sutphin
 */
public class TemplateResource extends AbstractStorableDomainObjectResource<Study> {
    private StudyDao studyDao;

    @Override
    public void init(Context context, Request request, Response response) {
        super.init(context, request, response);
        setAllAuthorizedFor(Method.GET);
        setAuthorizedFor(Method.PUT, Role.STUDY_ADMIN);
        // TODO: temporary
        setXmlSerializer(new StudyXmlSerializer());
    }

    @Override
    protected Study loadRequestedObject(Request request) {
        String studyIdent = UriTemplateParameters.STUDY_IDENTIFIER.extractFrom(request);
        return studyDao.getByAssignedIdentifier(studyIdent);
    }

    ////// CONFIGURATION

    @Required
    public void setStudyDao(StudyDao studyDao) {
        this.studyDao = studyDao;
    }
}

package edu.northwestern.bioinformatics.studycalendar.restlets;

import edu.northwestern.bioinformatics.studycalendar.dao.StudyDao;
import edu.northwestern.bioinformatics.studycalendar.domain.Study;
import edu.northwestern.bioinformatics.studycalendar.domain.Role;
import edu.northwestern.bioinformatics.studycalendar.xml.writers.StudyXmlSerializer;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.data.Method;
import org.restlet.Context;
import org.springframework.beans.factory.annotation.Required;

/**
 * Resource representing a study and its planned calendar, including all amendments.
 *
 * @author Rhett Sutphin
 */
public class TemplateResource extends AbstractStorableDomainObjectResource<Study> {
    private StudyDao studyDao;

    @Override
    public void init(Context context, Request request, Response response) {
        super.init(context, request, response);
        setAllAuthorizedFor(Method.GET);
        setAuthorizedFor(Method.PUT, Role.STUDY_ADMIN);
    }

    @Override
    protected Study loadRequestedObject(Request request) {
        String studyIdent = UriTemplateParameters.STUDY_IDENTIFIER.extractFrom(request);
        return studyDao.getByAssignedIdentifier(studyIdent);
    }

    ////// CONFIGURATION

    @Required
    public void setStudyDao(StudyDao studyDao) {
        this.studyDao = studyDao;
    }
}

Remove mistakenly committed manual XML serializer injection


package com.vogella.android.testapp;

import android.app.Activity;
import android.databinding.DataBindingUtil;
import android.os.Bundle;

import com.vogella.android.testapp.databinding.ActivityMainBinding;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String textFieldValue ="";
        ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        MainActivityHandlers handler = new MainActivityHandlers();
        binding.setHandler(handler);
    }
}

package com.vogella.android.testapp;

import android.app.Activity;
import android.databinding.DataBindingUtil;
import android.os.Bundle;

import com.vogella.android.testapp.databinding.ActivityMainBinding;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        MainActivityHandlers handler = new MainActivityHandlers();
        binding.setHandler(handler);
    }
}

Delete unnecessary line in databinding example


/*
 * Copyright [2006] [University Corporation for Advanced Internet Development, Inc.]
 *
 * 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.opensaml.xml.encryption;

import java.security.KeyException;

import org.opensaml.xml.security.KeyInfoResolver;

/**
 * Resolves encrypted keys based on EncryptedData information or other external factors.
 */
public interface EncryptedKeyInfoResolver extends KeyInfoResolver {

    /**
     * Returns an encrypted key based on a particular EncryptedData context.
     *
     * @param encryptedData the EncryptedData context in which to look for EncryptedKey
     * @return the resolved EncryptedKey element
     * @throws KeyException thrown if there is a problem resolving a key
     */
    public EncryptedKey resolveKey(EncryptedData encryptedData) throws KeyException;

}

/*
 * Copyright [2006] [University Corporation for Advanced Internet Development, Inc.]
 *
 * 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.opensaml.xml.encryption;

import java.security.KeyException;
import java.security.PublicKey;

import org.opensaml.xml.security.KeyInfoResolver;

/**
 * Resolves encrypted keys based on EncryptedData information or other external factors.
 */
public interface EncryptedKeyInfoResolver extends KeyInfoResolver<PublicKey> {

    /**
     * Returns an encrypted key based on a particular EncryptedData context.
     *
     * @param encryptedData the EncryptedData context in which to look for EncryptedKey
     * @return the resolved EncryptedKey element
     * @throws KeyException thrown if there is a problem resolving a key
     */
    public EncryptedKey resolveKey(EncryptedData encryptedData) throws KeyException;

}

Set key type for resolver


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

package tachyon.security;

import java.security.Principal;

public class User implements Principal {
  private String mName;

  // TODO: add more attributes and methods for supporting Kerberos

  public User(String mName) {
    this.mName = mName;
  }

  @Override
  public String getName() {
    return mName;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    } else if (o == null || getClass() != o.getClass()) {
      return false;
    } else {
      return mName.equals(((User) o).mName);
    }
  }

  @Override
  public int hashCode() {
    return mName.hashCode();
  }

  @Override
  public String toString() {
    return mName;
  }
}

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

package tachyon.security;

import java.security.Principal;

public class User implements Principal {
  private String mName;

  // TODO: add more attributes and methods for supporting Kerberos

  public User(String name) {
    mName = name;
  }

  @Override
  public String getName() {
    return mName;
  }

  @Override
  public boolean equals(Object o) {
    if (o == null || getClass() != o.getClass()) {
      return false;
    } else {
      return mName.equals(((User) o).mName);
    }
  }

  @Override
  public int hashCode() {
    return mName.hashCode();
  }

  @Override
  public String toString() {
    return mName;
  }
}

Add user model - address comments


package com.push.pushapplication;

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

import org.jboss.aerogear.android.unifiedpush.PushConfig;
import org.jboss.aerogear.android.unifiedpush.PushRegistrar;
import org.jboss.aerogear.android.unifiedpush.Registrations;

import android.app.Application;

public class PushApplication extends Application {

    private final String VARIANT_ID       = "{{ variant.variantID }}";
    private final String SECRET           = "{{ variant.secret }}";
    private final String GCM_SENDER_ID    = "{{ variant.projectNumber }}";
    private final String UNIFIED_PUSH_URL = "{{ contextPath }}";

    private PushRegistrar registration;

    @Override
    public void onCreate() {
        super.onCreate();

        Registrations registrations = new Registrations();

        try {
            PushConfig config = new PushConfig(new URI(UNIFIED_PUSH_URL), GCM_SENDER_ID);
            config.setVariantID(VARIANT_ID);
            config.setSecret(SECRET);
            config.setAlias(MY_ALIAS);

            registration = registrations.push("unifiedpush", config);

            registration.register(getApplicationContext(), new Callback() {
                private static final long serialVersionUID = 1L;

                @Override
                public void onSuccess(Void ignore) {
                     Toast.makeText(MainActivity.this, "Registration Succeeded!",
                             Toast.LENGTH_LONG).show();
               }

               @Override
               public void onFailure(Exception exception) {
                     Log.e("MainActivity", exception.getMessage(), exception);
               }
            });

        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }
}

package com.push.pushapplication;

import android.util.Log;
import android.app.Application;

import org.jboss.aerogear.android.core.Callback;
import org.jboss.aerogear.android.unifiedpush.PushRegistrar;
import org.jboss.aerogear.android.unifiedpush.RegistrarManager;
import org.jboss.aerogear.android.unifiedpush.gcm.AeroGearGCMPushConfiguration;

public class PushApplication extends Application {

    private final String VARIANT_ID       = "{{ variant.variantID }}";
    private final String SECRET           = "{{ variant.secret }}";
    private final String GCM_SENDER_ID    = "{{ variant.projectNumber }}";
    private final String UNIFIED_PUSH_URL = "{{ contextPath }}";

    @Override
    public void onCreate() {
        super.onCreate();

        RegistrarManager.config("register", AeroGearGCMPushConfiguration.class)
                    .setPushServerURI(URI.create(UNIFIED_PUSH_URL))
                    .setSenderIds(GCM_SENDER_ID)
                    .setVariantID(VARIANT_ID)
                    .setSecret(SECRET)
                    .asRegistrar();

        PushRegistrar registrar = RegistrarManager.getRegistrar("register");
        registrar.register(getApplicationContext(), new Callback<Void>() {
            @Override
            public void onSuccess(Void data) {
                Log.i(TAG, "Registration Succeeded!");
            }

            @Override
            public void onFailure(Exception e) {
                Log.e(TAG, exception.getMessage(), exception);
            }
        });

    }
}

Update Android registration code snippet


import static org.junit.Assert.*;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class TetrisTest
{
    @Test
    public void shouldReturnTwo()
    {
        //assertEquals(Tetris.returnTwo(), 2);
    }
}

import static org.junit.Assert.*;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class TetrisTest
{

}

Add test for the main


package org.percepta.mgrankvi;

import java.io.Serializable;

/**
 * Position of component containing top and left position in relation to parent.
 *
 * @author Mikael Grankvist - Vaadin }>
 */
public class Position implements Serializable {

    private Integer topValue = 0;
    private Integer leftValue = 0;

    public Position() {
    }

    public Position(Integer topValue, Integer leftValue) {
        this.topValue = topValue;
        this.leftValue = leftValue;
    }

    public Integer getTopValue() {
        return topValue;
    }

    public void setTopValue(Integer topValue) {
        this.topValue = topValue;
    }

    public Integer getLeftValue() {
        return leftValue;
    }

    public void setLeftValue(Integer leftValue) {
        this.leftValue = leftValue;
    }

    public Integer[] toArray() {
        return new Integer[]{topValue, leftValue};
    }
}

package org.percepta.mgrankvi;

import java.io.Serializable;

/**
 * Position of component containing top and left position in relation to parent.
 *
 * @author Mikael Grankvist - Vaadin }>
 */
public class Position implements Serializable {

    private Integer topValue = 0;
    private Integer leftValue = 0;

    public Position() {
    }

    public Position(Integer leftValue, Integer topValue) {
        this.topValue = topValue;
        this.leftValue = leftValue;
    }

    public Integer getTopValue() {
        return topValue;
    }

    public void setTopValue(Integer topValue) {
        this.topValue = topValue;
    }

    public Integer getLeftValue() {
        return leftValue;
    }

    public void setLeftValue(Integer leftValue) {
        this.leftValue = leftValue;
    }

    public Integer[] toArray() {
        return new Integer[]{leftValue, topValue};
    }
}

Fix position to be (left, top) as we use it that way and not as written.


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

import aQute.bnd.annotation.Version;
import aQute.bnd.annotation.Export;

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

import aQute.bnd.annotation.Version;
import aQute.bnd.annotation.Export;

Implement tooling for tracing a node through the revision history Bump package export version


package com.iluwatar.callback;

/**
 *
 * Callback pattern is more native for functional languages where functions are treated as
 * first-class citizens. Prior to Java 8 callbacks can be simulated using simple (alike command)
 * interfaces.
 *
 */
public class App {

  /**
   * Program entry point
   */
  public static void main(String[] args) {
    Task task = new SimpleTask();
    Callback callback = new Callback() {
      @Override
      public void call() {
        System.out.println("I'm done now.");
      }
    };
    task.executeWith(callback);
  }
}

package com.iluwatar.callback;

/**
 *
 * Callback pattern is more native for functional languages where functions are treated as
 * first-class citizens. Prior to Java 8 callbacks can be simulated using simple (alike command)
 * interfaces.
 *
 */
public class App {

  /**
   * Program entry point
   */
  public static void main(String[] args) {
    Task task = new SimpleTask();
    Callback callback = () -> System.out.println("I'm done now.");
    task.executeWith(callback);
  }
}

Change callback to lambda expression


package com.wombatnation.privateer;

import static org.junit.Assert.assertEquals;

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

public class PrimitivesTest {

	private int intMethod(int a) {
		return a;
	}

//	@Test
	@Ignore
	public void testIntArg() throws Exception {
		Privateer p = new Privateer();

		int a = 1;
		Object result = p.callMethod(this, "intMethod", a);
		Integer i = (Integer) result;
		assertEquals(i.intValue(), a);
	}
}

package com.wombatnation.privateer;

import static org.junit.Assert.assertEquals;

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

public class PrimitivesTest {

	private int intMethod(int a) {
		return a;
	}

	@Test
	// Maven demands at least one runnable test
	public void makeMavenHappy() {

	}

//	@Test
	@Ignore
	public void testIntArg() throws Exception {
		Privateer p = new Privateer();

		int a = 1;
		Object result = p.callMethod(this, "intMethod", a);
		Integer i = (Integer) result;
		assertEquals(i.intValue(), a);
	}
}

Make annoying Maven happy by adding runnable test to in progress unit test file


package com.github.nylle.javafixture;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class Context {
    private final Configuration configuration;
    private final Map<Integer, Object> cache = new ConcurrentHashMap<>();

    public Context(Configuration configuration) {

        if (configuration == null) {
            throw new IllegalArgumentException("configuration: null");
        }

        this.configuration = configuration;
    }

    public Configuration getConfiguration() {
        return configuration;
    }

    public boolean isCached(SpecimenType type) {
        return cache.containsKey(type.hashCode());
    }

    public <T> T cached(SpecimenType type, T instance) {
        cache.putIfAbsent(type.hashCode(), instance);
        return (T) cache.get(type.hashCode());
    }

    public <T> T cached(SpecimenType type) {
        return (T) cache.get(type.hashCode());
    }
}

package com.github.nylle.javafixture;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class Context {
    private final Configuration configuration;
    private final Map<Integer, Object> cache;

    public Context(Configuration configuration) {

        if (configuration == null) {
            throw new IllegalArgumentException("configuration: null");
        }

        this.configuration = configuration;
        this.cache = new ConcurrentHashMap<>();
    }

    public Context(Configuration configuration, Map<Integer, Object> predefinedInstances) {

        if (configuration == null) {
            throw new IllegalArgumentException("configuration: null");
        }

        this.configuration = configuration;
        this.cache = new ConcurrentHashMap<>(predefinedInstances);
    }

    public Configuration getConfiguration() {
        return configuration;
    }

    public boolean isCached(SpecimenType type) {
        return cache.containsKey(type.hashCode());
    }

    public <T> T cached(SpecimenType type, T instance) {
        cache.putIfAbsent(type.hashCode(), instance);
        return (T) cache.get(type.hashCode());
    }

    public <T> T cached(SpecimenType type) {
        return (T) cache.get(type.hashCode());
    }

    public <T> T preDefined(SpecimenType type, T instance) {
        return cache.containsKey(type.hashCode()) ? (T) cache.get(type.hashCode()) : instance;
    }

}

Add read-only cache to context


/*
 * Copyright 2016 FabricMC
 *
 * 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 net.fabricmc.base;

import net.fabricmc.api.Side;
import net.minecraft.client.Minecraft;
import net.minecraft.sortme.EntityPlayerAbstract;

public class ClientSidedHandler implements ISidedHandler {

	@Override
	public Side getSide() {
		return Side.CLIENT;
	}

	@Override
	public EntityPlayerAbstract getClientPlayer() {
		return Minecraft.getInstance().player;
	}

	@Override
	public void runOnMainThread(Runnable runnable) {
		Minecraft.getInstance().scheduleOnMainThread(runnable);
	}

}

/*
 * Copyright 2016 FabricMC
 *
 * 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 net.fabricmc.base;

import net.fabricmc.api.Side;
import net.minecraft.client.Minecraft;
import net.minecraft.sortme.EntityPlayerAbstract;

public class ClientSidedHandler implements ISidedHandler {

	@Override
	public Side getSide() {
		return Side.CLIENT;
	}

	@Override
	public EntityPlayerAbstract getClientPlayer() {
		return Minecraft.getInstance().player;
	}

	@Override
	public void runOnMainThread(Runnable runnable) {
		if (Minecraft.getInstance().isMainThread()) {
			runnable.run();
		} else {
			Minecraft.getInstance().scheduleOnMainThread(runnable);
		}
	}

}

Check main thread before scheduling


package net.thechunk.playpen.utils;

import net.thechunk.playpen.protocol.Protocol;
import org.apache.commons.codec.binary.Hex;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class AuthUtils {

    public static String createHash(String key, String message) {
        return createHash(key, message.getBytes(StandardCharsets.UTF_8));
    }

    public static String createHash(String key, byte[] message) {
        MessageDigest digest;

        try {
            digest = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw new AssertionError(e);
        }

        String mpk = new String(message) + key;
        digest.update(mpk.getBytes());

        return Hex.encodeHexString(digest.digest());
    }

    public static boolean validateHash(String hash, String key, String message) {
        return validateHash(hash, key, message.getBytes(StandardCharsets.UTF_8));
    }

    public static boolean validateHash(String hash, String key, byte[] message) {
        return hash.equals(createHash(key, message));
    }

    public static boolean validateHash(Protocol.AuthenticatedMessage payload, String key) {
        return validateHash(payload.getHash(), key, payload.getPayload().toByteArray());
    }

    private AuthUtils() {}
}

package net.thechunk.playpen.utils;

import net.thechunk.playpen.protocol.Protocol;
import org.apache.commons.codec.binary.Hex;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class AuthUtils {

    public static String createHash(String key, String message) {
        return createHash(key, message.getBytes(StandardCharsets.UTF_8));
    }

    public static String createHash(String key, byte[] message) {
        MessageDigest digest;

        try {
            digest = MessageDigest.getInstance("SHA-1");
        } catch (NoSuchAlgorithmException e) {
            throw new AssertionError(e);
        }

        String mpk = new String(message) + key;
        digest.update(mpk.getBytes());

        return Hex.encodeHexString(digest.digest());
    }

    public static boolean validateHash(String hash, String key, String message) {
        return validateHash(hash, key, message.getBytes(StandardCharsets.UTF_8));
    }

    public static boolean validateHash(String hash, String key, byte[] message) {
        return hash.equals(createHash(key, message));
    }

    public static boolean validateHash(Protocol.AuthenticatedMessage payload, String key) {
        return validateHash(payload.getHash(), key, payload.getPayload().toByteArray());
    }

    private AuthUtils() {}
}

Revert "hashes are apparently not working, going to test md5 again"


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

/**
 * A base class for common functionality.
 *
 * @since 2.4.3
 */
public abstract class BaseObject {

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append(getClass().getSimpleName());
        builder.append(" [");
        toStringAppendFields(builder);
        builder.append("]");
        return builder.toString();
    }

    protected void toStringAppendFields(StringBuilder builder) {
        // do nothing by default, needed for b/w compatibility.
    }

}

Set svn:eol-style = native on Java files. No functional change.


package com.github.aureliano.edocs.app.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class AppFrame extends JFrame {

	private static final long serialVersionUID = 7618501026967569839L;

	public AppFrame() {
		this.buildGui();
	}

	private void buildGui() {
		super.setTitle("e-Docs");
		super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		JPanel panel = new JPanel(new BorderLayout());
		panel.setOpaque(true);
		super.setContentPane(panel);
	}

	public void showFrame() {
		super.pack();
		super.setVisible(true);
		super.setSize(new Dimension(500, 500));
	}
}

package com.github.aureliano.edocs.app.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.github.aureliano.edocs.app.gui.menu.MenuBar;

public class AppFrame extends JFrame {

	private static final long serialVersionUID = 7618501026967569839L;

	public AppFrame() {
		this.buildGui();
	}

	private void buildGui() {
		super.setTitle("e-Docs");
		super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		JPanel panel = new JPanel(new BorderLayout());
		panel.setOpaque(true);
		super.setContentPane(panel);

		super.setJMenuBar(new MenuBar());
	}

	public void showFrame() {
		super.pack();
		super.setVisible(true);
		super.setSize(new Dimension(500, 500));
	}
}

Set a menu bar to the frame.


package com.jstanier;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.googlecode.jcsv.CSVStrategy;
import com.googlecode.jcsv.reader.CSVReader;
import com.googlecode.jcsv.reader.internal.CSVReaderBuilder;

@Component
public class InputParser {

    @Autowired
    private InputReader inputReader;

    public List<TweetToSchedule> parseInput(String pathToCsvFile) {
        return parseCsvFile(pathToCsvFile);
    }

    private List<TweetToSchedule> parseCsvFile(String pathToCsvFile) {
        List<TweetToSchedule> csvData = null;
        try {
            Reader reader = inputReader.getInputReader(pathToCsvFile);
            CSVReader<TweetToSchedule> csvParser = createCSVReader(reader);
            csvData = csvParser.readAll();
        } catch (FileNotFoundException e) {
            exitWithError("File not found at " + pathToCsvFile);
        } catch (IOException e) {
            exitWithError("IO exception when reading " + pathToCsvFile);
        }
        return csvData;
    }

    private CSVReader<TweetToSchedule> createCSVReader(Reader reader) {
        return (CSVReader<TweetToSchedule>) new CSVReaderBuilder(reader)
                .strategy(CSVStrategy.UK_DEFAULT)
                .entryParser(new TweetToScheduleEntryParser()).build();
    }

    private void exitWithError(String error) {
        System.err.println(error);
        System.exit(1);
    }
}

package com.jstanier;

import java.io.IOException;
import java.io.Reader;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.googlecode.jcsv.CSVStrategy;
import com.googlecode.jcsv.reader.CSVReader;
import com.googlecode.jcsv.reader.internal.CSVReaderBuilder;

@Component
public class InputParser {

    @Autowired
    private InputReader inputReader;

    public List<TweetToSchedule> parseInput(String pathToCsvFile) {
        return parseCsvFile(pathToCsvFile);
    }

    private List<TweetToSchedule> parseCsvFile(String pathToCsvFile) {
        List<TweetToSchedule> csvData = null;
        Reader reader = inputReader.getInputReader(pathToCsvFile);
        CSVReader<TweetToSchedule> csvParser = createCSVReader(reader);
        try {
            csvData = csvParser.readAll();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return csvData;
    }

    private CSVReader<TweetToSchedule> createCSVReader(Reader reader) {
        return (CSVReader<TweetToSchedule>) new CSVReaderBuilder(reader)
                .strategy(CSVStrategy.UK_DEFAULT)
                .entryParser(new TweetToScheduleEntryParser()).build();
    }
}

Throw RuntimeException instead of System.exit


package sc.iview.ui;

import graphics.scenery.Node;

import javax.swing.*;

public class ContextPopUp extends JPopupMenu {

    JMenuItem anItem;
    public ContextPopUp(Node n) {
        anItem = new JMenuItem("I'm a " + n.getNodeType());
        add(anItem);
    }

}

package sc.iview.ui;

import graphics.scenery.Node;

import javax.swing.*;

public class ContextPopUp extends JPopupMenu {

    public ContextPopUp(Node n) {
        add( new JMenuItem("Name: " + n.getName()) );
        add( new JMenuItem("Type: " + n.getNodeType()) );
    }

}

Make context menu look a little more reasonable


package com.mcjty.rftools.blocks.teleporter;

import net.minecraft.entity.Entity;
import net.minecraft.world.Teleporter;
import net.minecraft.world.WorldServer;

public class RfToolsTeleporter extends Teleporter {
    private final WorldServer worldServerInstance;

    private double x;
    private double y;
    private double z;

    public RfToolsTeleporter(WorldServer world, double x, double y, double z) {
        super(world);
        this.worldServerInstance = world;
        this.x = x;
        this.y = y;
        this.z = z;

    }

    @Override
    public void placeInPortal(Entity pEntity, double p2, double p3, double p4, float p5) {
        this.worldServerInstance.getBlock((int) this.x, (int) this.y, (int) this.z);   //dummy load to maybe gen chunk

        pEntity.setPosition(this.x, this.y, this.z);
//        pEntity.setVelocity();
    }

}

package com.mcjty.rftools.blocks.teleporter;

import net.minecraft.entity.Entity;
import net.minecraft.world.Teleporter;
import net.minecraft.world.WorldServer;

public class RfToolsTeleporter extends Teleporter {
    private final WorldServer worldServerInstance;

    private double x;
    private double y;
    private double z;

    public RfToolsTeleporter(WorldServer world, double x, double y, double z) {
        super(world);
        this.worldServerInstance = world;
        this.x = x;
        this.y = y;
        this.z = z;

    }

    @Override
    public void placeInPortal(Entity pEntity, double p2, double p3, double p4, float p5) {
        this.worldServerInstance.getBlock((int) this.x, (int) this.y, (int) this.z);   //dummy load to maybe gen chunk

        pEntity.setPosition(this.x, this.y, this.z);
        pEntity.motionX = 0.0f;
        pEntity.motionY = 0.0f;
        pEntity.motionZ = 0.0f;
    }

}

Reset movement speed after going through a teleporter


package ru.yandex.qatools.allure.storages;

import ru.yandex.qatools.allure.model.Step;

import java.util.LinkedList;

/**
 * @author Dmitry Baev charlie@yandex-team.ru
 *         Date: 13.12.13
 */
public class StepStorage extends ThreadLocal<LinkedList<Step>> {
    @Override
    protected LinkedList<Step> initialValue() {
        LinkedList<Step> queue = new LinkedList<>();
        queue.add(new Step());
        return queue;
    }

    public Step getLast() {
        return get().getLast();
    }

    public void put(Step step) {
        get().add(step);
    }

    public Step pollLast() {
        return get().pollLast();
    }
}

package ru.yandex.qatools.allure.storages;

import ru.yandex.qatools.allure.model.Step;

import java.util.Deque;
import java.util.LinkedList;

/**
 * @author Dmitry Baev charlie@yandex-team.ru
 *         Date: 13.12.13
 */
public class StepStorage extends ThreadLocal<Deque<Step>> {
    @Override
    protected Deque<Step> initialValue() {
        Deque<Step> queue = new LinkedList<>();
        queue.add(new Step());
        return queue;
    }

    public Step getLast() {
        return get().getLast();
    }

    public void put(Step step) {
        get().add(step);
    }

    public Step pollLast() {
        return get().pollLast();
    }
}

Use interface instead of class in generic


/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2016 Abhijit Parida <abhijitparida.me@gmail.com>
 *
 * 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 OR COPYRIGHT HOLDERS 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 app.abhijit.iter;

import android.os.Bundle;
import android.preference.PreferenceFragment;

import app.abhijit.iter.R;

public class SettingsFragment extends PreferenceFragment {

    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);
    }
}

/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2016 Abhijit Parida <abhijitparida.me@gmail.com>
 *
 * 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 OR COPYRIGHT HOLDERS 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 app.abhijit.iter;

import android.os.Bundle;
import android.preference.PreferenceFragment;

public class SettingsFragment extends PreferenceFragment {

    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);
    }
}

Remove unused imports in settings fragment


/*
 * Copyright 2015 Google Inc.
 *
 * 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.google.template.soy.jbcsrc.restricted;

/** Holds flags controlling compiler behavior. */
public final class Flags {
  /**
   * Controls extra debug checks in the compiler that are generally redundant with bytecode
   * verification. Currently only enabled in tests.
   */
  public static final boolean DEBUG = true; // Boolean.getBoolean("soy_jbcsrc_debug_mode");

  private Flags() {}
}

/*
 * Copyright 2015 Google Inc.
 *
 * 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.google.template.soy.jbcsrc.restricted;

/** Holds flags controlling compiler behavior. */
public final class Flags {
  /**
   * Controls extra debug checks in the compiler that are generally redundant with bytecode
   * verification. Currently only enabled in tests.
   */
  public static final boolean DEBUG = Boolean.getBoolean("soy_jbcsrc_debug_mode");

  private Flags() {}
}

Disable the jbcsrc debug flag, this was accidentally left on in a debugging session.


package com.voxelwind.server.network.mcpe.packets;

import com.voxelwind.server.network.NetworkPackage;
import io.netty.buffer.ByteBuf;
import lombok.Data;

@Data
public class McpeResourcePackClientResponse implements NetworkPackage {
    private byte responceStatus;
    private short resourcePackIdVersions;

    @Override
    public void decode(ByteBuf buffer) {
        responceStatus = buffer.readByte();
        resourcePackIdVersions = buffer.readShort();
    }

    @Override
    public void encode(ByteBuf buffer) {

    }
}

package com.voxelwind.server.network.mcpe.packets;

import com.voxelwind.server.network.NetworkPackage;
import io.netty.buffer.ByteBuf;
import lombok.Data;

@Data
public class McpeResourcePackClientResponse implements NetworkPackage {
    private byte responseStatus;
    private short resourcePackIdVersions;

    @Override
    public void decode(ByteBuf buffer) {
        responseStatus = buffer.readByte();
        resourcePackIdVersions = buffer.readShort();
    }

    @Override
    public void encode(ByteBuf buffer) {

    }
}

Fix typo in field name (responce->response)


package org.ale.app;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class TwitterLinkCreatorTest {

	@Test
	public void shouldProcessSingleTwitterName() {
		String result = TwitterLinkCreator.process("@foobar");
		assertEquals("@foobar", result);
	}

	@Test
	public void shouldProcessSeveralTwitterNames() {
		String result = TwitterLinkCreator.process("@foo, @bar");
		assertEquals("@foo, @bar", result);
	}

	@Test
	public void shouldProcessNameWithUnderscore() {
		String result = TwitterLinkCreator.process("@foo_bar");
		assertEquals("@foo_bar", result);
	}
}

package org.ale.app;

import static org.junit.Assert.assertEquals;

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

public class TwitterLinkCreatorTest {

    private String twitterAddress;

    @Before
    public void setup(){
        twitterAddress = "@foobar", result);
	}

	@Test
	public void shouldProcessSeveralTwitterNames() {
		String result = TwitterLinkCreator.process("@foo, @bar");

        assertEquals(twitterAddress +"foo\">@foo, @bar", result);
	}

	@Test
	public void shouldProcessNameWithUnderscore() {
		String result = TwitterLinkCreator.process("@foo_bar");

        assertEquals(twitterAddress +"foo_bar\">@foo_bar", result);
	}
}

Refactor tests: Extracted the twitter address to a field


package de.prob2.ui.states;

import java.util.HashSet;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.sun.javafx.collections.ObservableSetWrapper;

import de.prob.model.representation.AbstractElement;
import javafx.collections.ObservableSet;

@Singleton
public class ClassBlacklist {
	private final ObservableSet<Class<? extends AbstractElement>> blacklist;
	private final ObservableSet<Class<? extends AbstractElement>> knownClasses;

	@Inject
	private ClassBlacklist() {
		super();
		this.blacklist = new ObservableSetWrapper<>(new HashSet<>());
		this.knownClasses = new ObservableSetWrapper<>(new HashSet<>());
	}

	public ObservableSet<Class<? extends AbstractElement>> getBlacklist() {
		return this.blacklist;
	}

	public ObservableSet<Class<? extends AbstractElement>> getKnownClasses() {
		return this.knownClasses;
	}
}

package de.prob2.ui.states;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import de.prob.model.representation.AbstractElement;
import javafx.collections.FXCollections;
import javafx.collections.ObservableSet;

@Singleton
public final class ClassBlacklist {
	private final ObservableSet<Class<? extends AbstractElement>> blacklist;
	private final ObservableSet<Class<? extends AbstractElement>> knownClasses;

	@Inject
	@SuppressWarnings("unchecked")
	private ClassBlacklist() {
		super();
		this.blacklist = FXCollections.observableSet();
		this.knownClasses = FXCollections.observableSet();
	}

	public ObservableSet<Class<? extends AbstractElement>> getBlacklist() {
		return this.blacklist;
	}

	public ObservableSet<Class<? extends AbstractElement>> getKnownClasses() {
		return this.knownClasses;
	}
}

Replace use of com.sun ObservableSetWrapper with FXCollections


package scoutmgr.server.rest;

import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath( "/api" )
public class JaxRsActivator
  extends Application
{
  @Override
  public Set<Class<?>> getClasses()
  {
    final Set<Class<?>> classes = new HashSet<>();
    classes.addAll( super.getClasses() );
    classes.add( ScoutmgrSessionRestService.class );
    classes.add( ScoutmgrReplicantPollRestService.class );
    classes.add( ScoutmgrBadSessionExceptionMapper.class );
    return classes;
  }
}

package scoutmgr.server.rest;

import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath( "/api" )
public class JaxRsActivator
  extends Application
{
  @Override
  public Set<Class<?>> getClasses()
  {
    final Set<Class<?>> classes = new HashSet<>();
    classes.addAll( super.getClasses() );
    classes.add( ScoutmgrSessionRestService.class );
    classes.add( ScoutmgrReplicantPollRestService.class );
    return classes;
  }
}

Remove mapper. Unsure why we are keeping this class at all.


package com.pengrad.telegrambot;

import com.google.gson.Gson;
import com.pengrad.telegrambot.impl.FileApi;
import com.pengrad.telegrambot.impl.TelegramBotClient;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;

/**
 * stas
 * 8/4/15.
 */
public class TelegramBotAdapter {

    public static final String API_URL = "https://api.telegram.org/bot";

    public static TelegramBot build(String botToken) {
        FileApi fileApi = new FileApi(botToken);
        TelegramBotClient api = new TelegramBotClient(client(null), gson(), apiUrl(botToken));
        return new TelegramBot(api, fileApi);
    }

    public static TelegramBot buildDebug(String botToken) {
        FileApi fileApi = new FileApi(botToken);
        TelegramBotClient api = new TelegramBotClient(client(httpLoggingInterceptor()), gson(), apiUrl(botToken));
        return new TelegramBot(api, fileApi);
    }

    private static OkHttpClient client(Interceptor interceptor) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        if (interceptor != null) builder.addInterceptor(interceptor);
        return builder.build();
    }

    private static Interceptor httpLoggingInterceptor() {
        return new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY);
    }

    private static Gson gson() {
        return new Gson();
    }

    private static String apiUrl(String botToken) {
        return API_URL + botToken + "/";
    }
}

package com.pengrad.telegrambot;

import com.google.gson.Gson;
import com.pengrad.telegrambot.impl.FileApi;
import com.pengrad.telegrambot.impl.TelegramBotClient;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;

/**
 * stas
 * 8/4/15.
 */
public class TelegramBotAdapter {

    public static final String API_URL = "https://api.telegram.org/bot";

    public static TelegramBot build(String botToken) {
        return buildCustom(botToken, client(null));
    }

    public static TelegramBot buildDebug(String botToken) {
        return buildCustom(botToken, client(httpLoggingInterceptor()));
    }

    public static TelegramBot buildCustom(String botToken, OkHttpClient okHttpClient) {
        TelegramBotClient client = new TelegramBotClient(okHttpClient, gson(), apiUrl(botToken));
        FileApi fileApi = new FileApi(botToken);
        return new TelegramBot(client, fileApi);
    }

    private static OkHttpClient client(Interceptor interceptor) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        if (interceptor != null) builder.addInterceptor(interceptor);
        return builder.build();
    }

    private static Interceptor httpLoggingInterceptor() {
        return new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY);
    }

    private static Gson gson() {
        return new Gson();
    }

    private static String apiUrl(String botToken) {
        return API_URL + botToken + "/";
    }
}

Add support for custom OkHttpClient when creating bot


/*
 * Copyright (c) 2000-2016 TeamDev Ltd. All rights reserved.
 * Use is subject to Apache 2.0 license terms.
 */

package com.teamdev.jxmaps.examples;

import javax.swing.*;

public interface ControlPanel {
    JComponent getControlPanel();

    void configureControlPanel();

    int getPreferredHeight();
}

Remove excessive empty line after copyright header


package examples.dustin.commandline.picocli;

import static java.lang.System.out;

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

/**
 * Demonstrate Java-based command-line processing with picocli.
 */
@Command(
   name="Main",
   description="@|bold Demonstrating picocli @|",
   headerHeading="@|bold,underline Demonstration Usage|@:%n%n")
public class Main
{
   @Option(names={"-v", "--verbose"}, description="Verbose output?")
   private boolean verbose;

   @Option(names={"-f", "--file"}, description="Path and name of file", required=true)
   private String fileName;

   @Option(names={"-h", "--help"}, description="Display help/usage.", help=true)
   boolean help;

   public static void main(final String[] arguments)
   {
      final Main main = CommandLine.populateCommand(new Main(), arguments);
      if (main.help)
      {
         CommandLine.usage(main, out, CommandLine.Help.Ansi.AUTO);
      }
      else
      {
         out.println("The provided file path and name is " + main.fileName + " and verbosity is set to " + main.verbose);
      }
   }
}

package examples.dustin.commandline.picocli;

import static java.lang.System.out;

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

/**
 * Demonstrate Java-based command-line processing with picocli.
 */
@Command(
   name="Main",
   description="@|bold Demonstrating picocli |@",
   headerHeading="@|bold,underline Demonstration Usage|@:%n%n")
public class Main
{
   @Option(names={"-v", "--verbose"}, description="Verbose output?")
   private boolean verbose;

   @Option(names={"-f", "--file"}, description="Path and name of file", required=true)
   private String fileName;

   @Option(names={"-h", "--help"}, description="Display help/usage.", help=true)
   boolean help;

   public static void main(final String[] arguments)
   {
      final Main main = CommandLine.populateCommand(new Main(), arguments);
      if (main.help)
      {
         CommandLine.usage(main, out, CommandLine.Help.Ansi.AUTO);
      }
      else
      {
         out.println("The provided file path and name is " + main.fileName + " and verbosity is set to " + main.verbose);
      }
   }
}

Fix descriptions color styling termination


package openmods.core;

import java.util.Map;

import net.minecraft.launchwrapper.Launch;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.SortingIndex;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;

//must be lower than all dependent ones
@SortingIndex(16)
@TransformerExclusions({ "openmods.asm.", "openmods.include.", "openmods.core.", "openmods.injector.", "openmods.Log" })
public class OpenModsCorePlugin implements IFMLLoadingPlugin {

	public static final String CORE_MARKER = "OpenModsCoreLoaded";

	public OpenModsCorePlugin() {
		Launch.blackboard.put(CORE_MARKER, "$LIB-VERSION$");
	}

	@Override
	public String[] getASMTransformerClass() {
		return new String[] { "openmods.core.OpenModsClassTransformer" };
	}

	@Override
	public String getModContainerClass() {
		return "openmods.core.OpenModsCore";
	}

	@Override
	public String getSetupClass() {
		return null;
	}

	@Override
	public void injectData(Map<String, Object> data) {
		Bootstrap.injectData(data);
	}

	@Override
	public String getAccessTransformerClass() {
		return null;
	}

}

package openmods.core;

import java.util.Map;

import net.minecraft.launchwrapper.Launch;
import openmods.Log;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.SortingIndex;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;

//must be lower than all dependent ones
@SortingIndex(16)
@TransformerExclusions({ "openmods.asm.", "openmods.include.", "openmods.core.", "openmods.injector.", "openmods.Log" })
public class OpenModsCorePlugin implements IFMLLoadingPlugin {

	public static final String CORE_MARKER = "OpenModsCoreLoaded";

	public OpenModsCorePlugin() {
		Log.debug("<OpenModsLib %s>\\o", "$LIB-VERSION$");
		Launch.blackboard.put(CORE_MARKER, "$LIB-VERSION$");
	}

	@Override
	public String[] getASMTransformerClass() {
		return new String[] { "openmods.core.OpenModsClassTransformer" };
	}

	@Override
	public String getModContainerClass() {
		return "openmods.core.OpenModsCore";
	}

	@Override
	public String getSetupClass() {
		return null;
	}

	@Override
	public void injectData(Map<String, Object> data) {
		Bootstrap.injectData(data);
	}

	@Override
	public String getAccessTransformerClass() {
		return null;
	}

}

Debug log in core plugin


package org.jboss.msc.bench;

import java.util.concurrent.CountDownLatch;
import org.jboss.msc.registry.ServiceDefinition;
import org.jboss.msc.registry.ServiceRegistrationBatchBuilder;
import org.jboss.msc.registry.ServiceRegistry;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.TimingServiceListener;

public class NoDepBench {

    public static void main(String[] args) throws Exception {
        final int totalServiceDefinitions = Integer.parseInt(args[0]);

        ServiceRegistrationBatchBuilder batch = ServiceRegistry.Factory.create(ServiceContainer.Factory.create()).batchBuilder();

        final CountDownLatch latch = new CountDownLatch(1);
        final TimingServiceListener listener = new TimingServiceListener(new TimingServiceListener.FinishListener() {
            public void done(final TimingServiceListener timingServiceListener) {
                latch.countDown();
            }
        });
        for (int i = 0; i < totalServiceDefinitions; i++) {
            batch.add(ServiceDefinition.build(ServiceName.of("test" + i), Service.NULL_VALUE).addListener(listener).create());
        }
        batch.install();
        listener.finishBatch();
        latch.await();
        System.out.println(totalServiceDefinitions + " : "  + listener.getElapsedTime() + "ms");
    }
}

package org.jboss.msc.bench;

import java.util.concurrent.CountDownLatch;
import org.jboss.msc.registry.ServiceDefinition;
import org.jboss.msc.registry.ServiceRegistrationBatchBuilder;
import org.jboss.msc.registry.ServiceRegistry;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.TimingServiceListener;

public class NoDepBench {

    public static void main(String[] args) throws Exception {
        final int totalServiceDefinitions = Integer.parseInt(args[0]);

        ServiceRegistrationBatchBuilder batch = ServiceRegistry.Factory.create(ServiceContainer.Factory.create()).batchBuilder();

        final CountDownLatch latch = new CountDownLatch(1);
        final TimingServiceListener listener = new TimingServiceListener(new TimingServiceListener.FinishListener() {
            public void done(final TimingServiceListener timingServiceListener) {
                latch.countDown();
            }
        });
        for (int i = 0; i < totalServiceDefinitions; i++) {
            batch.add(ServiceDefinition.build(ServiceName.of("test" + i), Service.NULL_VALUE).addListener(listener).create());
        }
        batch.install();
        listener.finishBatch();
        latch.await();
        System.out.println(totalServiceDefinitions + " : "  + listener.getElapsedTime() / 1000.0);
    }
}

Use fractional seconds to compare


package com.faforever.api.data.domain;

public enum Validity {
  // Order is crucial
  VALID,
  TOO_MANY_DESYNCS,
  WRONG_VICTORY_CONDITION,
  NO_FOG_OF_WAR,
  CHEATS_ENABLED,
  PREBUILT_ENABLED,
  NORUSH_ENABLED,
  BAD_UNIT_RESTRICTIONS,
  BAD_MAP,
  TOO_SHORT,
  BAD_MOD,
  COOP_NOT_RANKED,
  MUTUAL_DRAW,
  SINGLE_PLAYER,
  FFA_NOT_RANKED,
  UNEVEN_TEAMS_NOT_RANKED,
  UNKNOWN_RESULT,
  TEAMS_UNLOCKED,
  MULTIPLE_TEAMS,
  HAS_AI,
  CIVILIANS_REVEALED,
  WRONG_DIFFICULTY,
  EXPANSION_DISABLED,
  SPAWN_NOT_FIXED,
  OTHER_UNRANK
}

package com.faforever.api.data.domain;

public enum Validity {
  // Order is crucial
  VALID,
  TOO_MANY_DESYNCS,
  WRONG_VICTORY_CONDITION,
  NO_FOG_OF_WAR,
  CHEATS_ENABLED,
  PREBUILT_ENABLED,
  NORUSH_ENABLED,
  BAD_UNIT_RESTRICTIONS,
  BAD_MAP,
  TOO_SHORT,
  BAD_MOD,
  COOP_NOT_RANKED,
  MUTUAL_DRAW,
  SINGLE_PLAYER,
  FFA_NOT_RANKED,
  UNEVEN_TEAMS_NOT_RANKED,
  UNKNOWN_RESULT,
  TEAMS_UNLOCKED,
  MULTIPLE_TEAMS,
  HAS_AI,
  CIVILIANS_REVEALED,
  WRONG_DIFFICULTY,
  EXPANSION_DISABLED,
  SPAWN_NOT_FIXED,
  OTHER_UNRANK,
  UNRANKED_BY_HOST
}

Add new validity state for games unranked by host


/*
 * Copyright 2006-2014 innopost.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 * or in the "license" file accompanying this file. This file 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.popbill.api.taxinvoice;

/**
 * Enum for MgtKeyType.
 *
 * @author KimSeonjun
 * @version 1.0.0
 */
public enum MgtKeyType {
	/**
	 * 매출
	 */
	SELL,
	/**
	 * 매입
	 */
	BUY,
	/**
	 * 수탁
	 */
	TRUST
}

/*
 * Copyright 2006-2014 innopost.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 * or in the "license" file accompanying this file. This file 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.popbill.api.taxinvoice;

/**
 * Enum for MgtKeyType.
 *
 * @author KimSeonjun
 * @version 1.0.0
 */
public enum MgtKeyType {
	/**
	 * 매출
	 */
	SELL,
	/**
	 * 매입
	 */
	BUY,
	/**
	 * 수탁
	 */
	TRUSTEE
}

Fix Typo bug. TRUST -> TRUSTEE


package com.example.android.miwok;

public class Word {

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

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

    public Word(String miwokWord, String englishWord, int imageResourceId, int rawResourceId) {
        mMiwokWord = miwokWord;
        mEnglishWord = englishWord;
        mImageResourceId = imageResourceId;
        mRawResourceId = rawResourceId;
    } // 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 res ID for icon image resource;
    public int getmImageResourceId() { return mImageResourceId; }

    // Getter method to retrieve res ID for mp3 resource;
    public int getmRawResourceId() { return mRawResourceId; }

} // Close class Word

package com.example.android.miwok;

public class Word {

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

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

    // Constructor setter method, overloaded
    // Extra @param imageResourceId
    public Word(String miwokWord, String englishWord, int imageResourceId, int rawResourceId) {
        mMiwokWord = miwokWord;
        mEnglishWord = englishWord;
        mImageResourceId = imageResourceId;
        mRawResourceId = rawResourceId;
    } // 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 res ID for icon image resource;
    public int getmImageResourceId() { return mImageResourceId; }

    // Getter method to retrieve res ID for mp3 resource;
    public int getmRawResourceId() { return mRawResourceId; }

} // Close class Word

Clarify comments about overloaded constructor


package top.quantic.sentry.config;

import com.google.common.cache.CacheBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
@EnableCaching
@AutoConfigureAfter(value = {MetricsConfiguration.class})
@AutoConfigureBefore(value = {WebConfigurer.class, DatabaseConfiguration.class})
public class CacheConfiguration {

    private final Logger log = LoggerFactory.getLogger(CacheConfiguration.class);

    @Bean
    public CacheManager cacheManager() {
        log.debug("Creating Guava cache manager");
        GuavaCacheManager guavaCacheManager = new GuavaCacheManager();
        guavaCacheManager.setCacheBuilder(CacheBuilder.newBuilder().expireAfterAccess(3, TimeUnit.HOURS));
        return guavaCacheManager;
    }
}

package top.quantic.sentry.config;

import com.google.common.cache.CacheBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
@EnableCaching
@AutoConfigureAfter(value = {MetricsConfiguration.class})
@AutoConfigureBefore(value = {WebConfigurer.class, DatabaseConfiguration.class})
public class CacheConfiguration {

    private final Logger log = LoggerFactory.getLogger(CacheConfiguration.class);

    @Bean
    public CacheManager cacheManager() {
        log.debug("Creating Guava cache manager");
        GuavaCacheManager guavaCacheManager = new GuavaCacheManager();
        guavaCacheManager.setCacheBuilder(CacheBuilder.newBuilder().expireAfterAccess(30, TimeUnit.MINUTES));
        return guavaCacheManager;
    }
}

Reduce cache expiration time to 30 minutes


// Copyright (C) 2003-2009 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the CPL Common Public License version 1.0.
package fitnesse.fixtures;

import util.FileUtil;

import java.io.File;

public class FileSection {
  private static File fileSection;

  public FileSection(String type) throws Exception {
    if ("setup".equals(type.toLowerCase())) {
      new File(FitnesseFixtureContext.baseDir).mkdir();
      File dir = new File(FitnesseFixtureContext.baseDir);
      dir.mkdir();
      fileSection = new File(dir, "files");
      fileSection.mkdir();
    } else {
      FileUtil.deleteFileSystemDirectory(FitnesseFixtureContext.baseDir);
      fileSection = null;
    }
  }

  public static File getFileSection() {
    return fileSection;
  }

}

// Copyright (C) 2003-2009 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the CPL Common Public License version 1.0.
package fitnesse.fixtures;

import util.FileUtil;

import java.io.File;

public class FileSection {
  private static File fileSection;

  public FileSection(String type) throws Exception {
    if ("setup".equals(type.toLowerCase())) {
      File dir = new File(FitnesseFixtureContext.context.getRootPagePath());
      dir.mkdir();
      fileSection = new File(dir, "files");
      fileSection.mkdir();
    } else {
      FileUtil.deleteFileSystemDirectory(FitnesseFixtureContext.context.getRootPagePath());
      fileSection = null;
    }
  }

  public static File getFileSection() {
    return fileSection;
  }

}

Use correct directory for file section AT.


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

import com.facebook.soloader.SoLoader;

public class YogaJNI {

  // Known constants. 1-3 used in previous experiments. Do not reuse.
  public static int JNI_FAST_CALLS = 4;

  // set before loading any other Yoga code
  public static boolean useFastCall = false;

  private static native void jni_bindNativeMethods(boolean useFastCall);

  static boolean init() {
    if (SoLoader.loadLibrary("yoga")) {
      jni_bindNativeMethods(useFastCall);
      return true;
    }

    return false;
  }
}

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

import com.facebook.soloader.SoLoader;

public class YogaJNI {
  private static boolean isInitialized = false;

  // Known constants. 1-3 used in previous experiments. Do not reuse.
  public static int JNI_FAST_CALLS = 4;

  // set before loading any other Yoga code
  public static boolean useFastCall = false;

  private static native void jni_bindNativeMethods(boolean useFastCall);

  static synchronized boolean init() {
    if (!isInitialized) {
      isInitialized = true;
      SoLoader.loadLibrary("yoga");
      jni_bindNativeMethods(useFastCall);
      return true;
    }
    return false;
  }
}

Add Yoga JNI bindings to libcoldstart