package com.litl.leveldb;

import java.io.Closeable;
import java.util.concurrent.atomic.AtomicInteger;

import android.util.Log;

abstract class NativeObject implements Closeable {
    private static final String TAG = NativeObject.class.getSimpleName();
    protected long mPtr;
    private AtomicInteger mRefCount = new AtomicInteger();

    protected NativeObject() {
        // The Java wrapper counts as one reference, will
        // be released when closed
        ref();
    }

    protected NativeObject(long ptr) {
        this();

        if (ptr == 0) {
            throw new OutOfMemoryError("Failed to allocate native object");
        }

        mPtr = ptr;
    }

    protected long getPtr() {
        return mPtr;
    }

    protected void assertOpen(String message) {
        if (mPtr == 0) {
            throw new IllegalStateException(message);
        }
    }

    void ref() {
        mRefCount.incrementAndGet();
    }

    void unref() {
        if (mRefCount.decrementAndGet() == 0) {
            closeNativeObject(mPtr);
            mPtr = 0;
        }
    }

    protected abstract void closeNativeObject(long ptr);

    @Override
    public void close() {
        unref();
    }

    @Override
    protected void finalize() throws Throwable {
        if (mPtr != 0) {
            Log.w(TAG,
                    "NativeObject "
                            + getClass().getSimpleName()
                            + " was finalized before native resource was closed, did you forget to call close()?");
        }

        super.finalize();
    }
}

package com.litl.leveldb;

import java.io.Closeable;

import android.util.Log;

abstract class NativeObject implements Closeable {
    private static final String TAG = NativeObject.class.getSimpleName();
    protected long mPtr;
    private int mRefCount = 0;

    protected NativeObject() {
        // The Java wrapper counts as one reference, will
        // be released when closed
        ref();
    }

    protected NativeObject(long ptr) {
        this();

        if (ptr == 0) {
            throw new OutOfMemoryError("Failed to allocate native object");
        }

        mPtr = ptr;
    }

    synchronized protected long getPtr() {
        return mPtr;
    }

    protected void assertOpen(String message) {
        if (getPtr() == 0) {
            throw new IllegalStateException(message);
        }
    }

    synchronized void ref() {
        mRefCount++;
    }

    synchronized void unref() {
        if (mRefCount <= 0) {
            throw new IllegalStateException("Reference count is already 0");
        }

        mRefCount--;

        if (mRefCount == 0) {
            closeNativeObject(mPtr);
            mPtr = 0;
        }
    }

    protected abstract void closeNativeObject(long ptr);

    @Override
    public void close() {
        unref();
    }

    @Override
    protected void finalize() throws Throwable {
        if (mPtr != 0) {
            Log.w(TAG,
                    "NativeObject "
                            + getClass().getSimpleName()
                            + " was finalized before native resource was closed, did you forget to call close()?");
        }

        super.finalize();
    }
}

Add additional checks in unref()


package com.btk5h.skriptmirror.skript.custom;

import org.bukkit.event.Event;

import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;

public class CustomSyntaxExpression extends SimpleExpression<Object> {
  private Expression<?> source;
  private Event realEvent;

  public CustomSyntaxExpression(Expression<?> source, Event realEvent) {
    this.source = source;
    this.realEvent = realEvent;
  }

  public static CustomSyntaxExpression wrap(Expression<?> source, Event realEvent) {
    if (source instanceof CustomSyntaxExpression) {
      return (CustomSyntaxExpression) source;
    }
    return new CustomSyntaxExpression(source, realEvent);
  }

  @Override
  protected Object[] get(Event e) {
    return source.getAll(realEvent);
  }

  @Override
  public boolean isSingle() {
    return source.isSingle();
  }

  @Override
  public Class<?> getReturnType() {
    return source.getReturnType();
  }

  @Override
  public String toString(Event e, boolean debug) {
    return source.toString(realEvent, debug);
  }

  @Override
  public Expression<?> getSource() {
    return source;
  }

  @Override
  public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
    throw new UnsupportedOperationException();
  }
}

package com.btk5h.skriptmirror.skript.custom;

import org.bukkit.event.Event;

import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;

public class CustomSyntaxExpression extends SimpleExpression<Object> {
  private Expression<?> source;
  private Event realEvent;

  public CustomSyntaxExpression(Expression<?> source, Event realEvent) {
    this.source = source;
    this.realEvent = realEvent;
  }

  public static CustomSyntaxExpression wrap(Expression<?> source, Event realEvent) {
    if (source instanceof CustomSyntaxExpression) {
      return (CustomSyntaxExpression) source;
    }
    return new CustomSyntaxExpression(source, realEvent);
  }

  @Override
  protected Object[] get(Event e) {
    return source == null ? new Object[0] : source.getAll(realEvent);
  }

  @Override
  public boolean isSingle() {
    return source == null || source.isSingle();
  }

  @Override
  public Class<?> getReturnType() {
    return source == null ? Object.class : source.getReturnType();
  }

  @Override
  public String toString(Event e, boolean debug) {
    return source == null ? "" : source.toString(realEvent, debug);
  }

  @Override
  public Expression<?> getSource() {
    return source;
  }

  @Override
  public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
    throw new UnsupportedOperationException();
  }
}

Fix NPE with nullable expressions in custom syntax


package net.gpdev.gameoflife;

public class GameOfLife {
    private final int xDim;
    private final int yDim;

    private Grid current;
    private Grid next;

    public GameOfLife(int xDim, int yDim) {
        this.xDim = xDim;
        this.yDim = yDim;
        current = new Grid(xDim, yDim);
        next = new Grid(xDim, yDim);
    }

    public void populateCell(int x, int y) {
        current.set(x, y);
    }

    public boolean isCellPopulated(int x, int y) {
        return !current.isEmpty(x, y);
    }

    public void tick() {
        for (int i = 0; i < xDim; i++) {
            for (int j = 0; j < yDim; j++) {
                if (current.isEmpty(i, j)) {
                    if (current.numNeighbors(i, j) == 3) {
                        next.set(i, j);
                    }
                }
                else {
                    final int numNeighbors = current.numNeighbors(i, j);
                    if (numNeighbors == 2 || numNeighbors == 3) {
                        next.set(i, j);
                    }
                }
            }
        }
        current = next;
    }

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

package net.gpdev.gameoflife;

public class GameOfLife {
    private final int xDim;
    private final int yDim;

    private Grid current;
    private Grid next;

    public GameOfLife(int xDim, int yDim) {
        this.xDim = xDim;
        this.yDim = yDim;
        current = new Grid(xDim, yDim);
        next = new Grid(xDim, yDim);
    }

    public void populateCell(int x, int y) {
        current.set(x, y);
    }

    public boolean isCellPopulated(int x, int y) {
        return !current.isEmpty(x, y);
    }

    public void tick() {
        for (int i = 0; i < xDim; i++) {
            for (int j = 0; j < yDim; j++) {
                if (current.isEmpty(i, j)) {
                    if (current.numNeighbors(i, j) == 3) {
                        next.set(i, j);
                    } else {
                        next.unset(i, j);
                    }
                } else {
                    final int numNeighbors = current.numNeighbors(i, j);
                    if (numNeighbors == 2 || numNeighbors == 3) {
                        next.set(i, j);
                    } else {
                        next.unset(i, j);
                    }
                }
            }
        }

        final Grid prev = current;
        current = next;
        next = prev;
    }

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

Correct game.tick() implementation and pass failing test


package info.u_team.u_team_test.init;

import info.u_team.u_team_test.TestMod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;

@EventBusSubscriber(modid = TestMod.MODID, bus = Bus.FORGE)
public class TestDimensions {

	// TODO wait for forge replacement
	// @SuppressWarnings("deprecation")
	// @SubscribeEvent
	// public static void on(RegisterDimensionsEvent event) {
	// if (!DimensionManager.getRegistry().keySet().contains(TestModDimensions.BASIC.getId())) { // How do we know when the
	// dimension needs to be registered??
	// DimensionManager.registerDimension(TestModDimensions.BASIC.getId(), TestModDimensions.BASIC.get(), null, true);
	// }
	// }
}

package info.u_team.u_team_test.init;

public class TestDimensions {

	// TODO wait for forge replacement
	// @SuppressWarnings("deprecation")
	// @SubscribeEvent
	// public static void on(RegisterDimensionsEvent event) {
	// if (!DimensionManager.getRegistry().keySet().contains(TestModDimensions.BASIC.getId())) { // How do we know when the
	// dimension needs to be registered??
	// DimensionManager.registerDimension(TestModDimensions.BASIC.getId(), TestModDimensions.BASIC.get(), null, true);
	// }
	// }
}

Remove annotation on outdated stuff


/*
 * 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.apache.karaf.cellar.shell.group;

import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;

@Command(scope = "cluster", name = "group-create", description = "Create a cluster group.")
public class GroupCreateCommand extends GroupSupport {

    @Argument(index = 0, name = "group", description = "The cluster group name.", required = false, multiValued = false)
    String group;

    @Override
    protected Object doExecute() throws Exception {
        return groupManager.createGroup(group);
    }

}

/*
 * 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.apache.karaf.cellar.shell.group;

import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;

@Command(scope = "cluster", name = "group-create", description = "Create a cluster group.")
public class GroupCreateCommand extends GroupSupport {

    @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
    String group;

    @Override
    protected Object doExecute() throws Exception {
        return groupManager.createGroup(group);
    }

}

Set group argument as required in cluster:group-create command


package ro.stancalau.lombok.examples.correct;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode
public class ExtendedEqualableParent extends EqualableParent {
}

package ro.stancalau.lombok.examples.correct;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
public class ExtendedEqualableParent extends EqualableParent {
}

Add call super option for @EqualsAndHashCode to avoid build warning.


/*
 * Framework.java
 *
 * Copyright (c) 2015 Mike Strobel
 *
 * This source code is subject to terms and conditions of the Apache License, Version 2.0.
 * A copy of the license can be found in the License.html file at the root of this distribution.
 * By using this source code in any fashion, you are agreeing to be bound by the terms of the
 * Apache License, Version 2.0.
 *
 * You must not remove this notice, or any other, from this software.
 */

package com.strobel;

public final class Procyon {
    private static final String VERSION = "1.0-SNAPSHOT";
    private static final String VERSION_SUFFIX = "enigma";

    public static String version() {
        return VERSION;
    }
}

/*
 * Framework.java
 *
 * Copyright (c) 2015 Mike Strobel
 *
 * This source code is subject to terms and conditions of the Apache License, Version 2.0.
 * A copy of the license can be found in the License.html file at the root of this distribution.
 * By using this source code in any fashion, you are agreeing to be bound by the terms of the
 * Apache License, Version 2.0.
 *
 * You must not remove this notice, or any other, from this software.
 */

package com.strobel;

public final class Procyon {
    private static final String VERSION = "0.5.33";
    private static final String VERSION_SUFFIX = "enigma";

    public static String version() {
        return VERSION;
    }
}

Fix version number (update major)


/*
 * 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.imaging.formats.psd;

import org.junit.jupiter.api.Test;

import java.io.UnsupportedEncodingException;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class ImageResourceBlockTest{

    @Test
    public void testCreatesImageResourceBlockAndCallsGetName() throws UnsupportedEncodingException {
        final byte[] byteArray = new byte[3];
        final ImageResourceBlock imageResourceBlock = new ImageResourceBlock(0, byteArray, byteArray);

        assertEquals( new String(byteArray, "ISO-8859-1"), imageResourceBlock.getName());
    }

}

/*
 * 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.imaging.formats.psd;

import org.junit.jupiter.api.Test;

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

import static org.junit.jupiter.api.Assertions.assertEquals;

public class ImageResourceBlockTest{

    @Test
    public void testCreatesImageResourceBlockAndCallsGetName() throws UnsupportedEncodingException {
        final byte[] byteArray = new byte[3];
        final ImageResourceBlock imageResourceBlock = new ImageResourceBlock(0, byteArray, byteArray);

        assertEquals( new String(byteArray, StandardCharsets.ISO_8859_1), imageResourceBlock.getName());
    }

}

Use StandardCharsets instead of string value


package example;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

public class SocketClient {

    public static void main( String[] args ) throws IOException {
        // Check arguments
        if (args.length < 3) {
            System.err.println("Argument(s) missing!");
            System.err.printf("Usage: java %s host port file%n", SocketClient.class.getName());
            return;
        }

        String host = args[0];
        // Convert port from String to int
        int port = Integer.parseInt(args[1]);
        // Concatenate arguments using a string builder
        StringBuilder sb = new StringBuilder();
        for (int i = 2; i < args.length; i++) {
            sb.append(args[i]);
            if (i < args.length-1) {
                sb.append(" ");
            }
        }
        String text = sb.toString();

        // Create client socket
        Socket socket = new Socket(host, port);
        System.out.printf("Connected to server %s on port %d %n", Integer.valueOf(host), Integer.valueOf(port));

        // Create stream to send data to server
        DataOutputStream out = new DataOutputStream(socket.getOutputStream());

        // Send text to server as bytes
        out.writeBytes(text);
        out.writeBytes("\n");
        System.out.println("Sent text: " + text);

        // Close client socket
        socket.close();
        System.out.println("Connection closed");
    }
}

package example;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

public class SocketClient {

    public static void main( String[] args ) throws IOException {
        // Check arguments
        if (args.length < 3) {
            System.err.println("Argument(s) missing!");
            System.err.printf("Usage: java %s host port file%n", SocketClient.class.getName());
            return;
        }

        String host = args[0];
        // Convert port from String to int
        int port = Integer.parseInt(args[1]);
        // Concatenate arguments using a string builder
        StringBuilder sb = new StringBuilder();
        for (int i = 2; i < args.length; i++) {
            sb.append(args[i]);
            if (i < args.length-1) {
                sb.append(" ");
            }
        }
        String text = sb.toString();

        // Create client socket
        Socket socket = new Socket(host, port);
        System.out.printf("Connected to server %s on port %d %n", host, Integer.valueOf(port));

        // Create stream to send data to server
        DataOutputStream out = new DataOutputStream(socket.getOutputStream());

        // Send text to server as bytes
        out.writeBytes(text);
        out.writeBytes("\n");
        System.out.println("Sent text: " + text);

        // Close client socket
        socket.close();
        System.out.println("Connection closed");
    }
}

Fix String to Integer conversion bug


package org.ethereum.solidity;

import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertTrue;

import org.ethereum.solidity.Abi.Entry;
import org.ethereum.solidity.Abi.Entry.Type;
import org.junit.Test;

import java.io.IOException;

public class AbiTest {

    @Test
    public void simpleTest() throws IOException {
        String contractAbi = "[{"
                + "\"name\":\"simpleFunction\","
                + "\"constant\":true,"
                + "\"payable\":true,"
                + "\"type\":\"function\","
                + "\"inputs\": [{\"name\":\"_in\", \"type\":\"bytes32\"}],"
                + "\"outputs\":[{\"name\":\"_out\",\"type\":\"bytes32\"}]}]";

        Abi abi = Abi.fromJson(contractAbi);
        assertEquals(abi.size(), 1);

        Entry onlyFunc = abi.get(0);
        assertEquals(onlyFunc.type, Type.function);
        assertEquals(onlyFunc.inputs.size(), 1);
        assertEquals(onlyFunc.outputs.size(), 1);
        assertTrue(onlyFunc.payable);
        assertTrue(onlyFunc.constant);
    }

    public static void main(String[] args) throws Exception {
        new AbiTest().simpleTest();
    }
}

package org.ethereum.solidity;

import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertTrue;

import org.ethereum.solidity.Abi.Entry;
import org.ethereum.solidity.Abi.Entry.Type;
import org.junit.Test;

import java.io.IOException;

public class AbiTest {

    @Test
    public void simpleTest() throws IOException {
        String contractAbi = "[{"
                + "\"name\":\"simpleFunction\","
                + "\"constant\":true,"
                + "\"payable\":true,"
                + "\"type\":\"function\","
                + "\"inputs\": [{\"name\":\"_in\", \"type\":\"bytes32\"}],"
                + "\"outputs\":[{\"name\":\"_out\",\"type\":\"bytes32\"}]}]";

        Abi abi = Abi.fromJson(contractAbi);
        assertEquals(abi.size(), 1);

        Entry onlyFunc = abi.get(0);
        assertEquals(onlyFunc.type, Type.function);
        assertEquals(onlyFunc.inputs.size(), 1);
        assertEquals(onlyFunc.outputs.size(), 1);
        assertTrue(onlyFunc.payable);
        assertTrue(onlyFunc.constant);
    }

    @Test
    public void simpleLegacyTest() throws IOException {
        String contractAbi = "[{"
                + "\"name\":\"simpleFunction\","
                + "\"constant\":true,"
                + "\"type\":\"function\","
                + "\"inputs\": [{\"name\":\"_in\", \"type\":\"bytes32\"}],"
                + "\"outputs\":[{\"name\":\"_out\",\"type\":\"bytes32\"}]}]";

        Abi abi = Abi.fromJson(contractAbi);
        assertEquals(abi.size(), 1);

        Entry onlyFunc = abi.get(0);
        assertEquals(onlyFunc.type, Type.function);
        assertEquals(onlyFunc.inputs.size(), 1);
        assertEquals(onlyFunc.outputs.size(), 1);
        assertTrue(onlyFunc.constant);
    }
}

Add test for solc backward compatibility


/*
 * Copyright (c) 2016 RobotsByTheC. All rights reserved.
 *
 * Open Source Software - may be modified and shared by FRC teams. The code must
 * be accompanied by the BSD license file in the root directory of the project.
 */
package org.usfirst.frc.team2084.CMonster2016.commands;

import org.usfirst.frc.team2084.CMonster2016.vision.VisionParameters;

/**
 * Notifies the driver about whether the robot is ready to take a shot. This
 * prints a value on the SmartDashboard.
 *
 * @author Ben Wolsieffer
 */
public class SetCameraAutoExposure extends ParameterCommand {

    public static final String ENABLED_KEY = "Enabled";

    /**
     * Updates the SmartDashboard indicator based on whether the robot is ready
     * to shoot
     *
     * @param ready whether the robot is ready
     */
    public SetCameraAutoExposure(boolean enabled) {
        setRunWhenDisabled(true);
        addBooleanParameter(ENABLED_KEY, enabled);
    }

    @Override
    protected void initialize() {
        VisionParameters.setAutoExposure(getBooleanParameter(ENABLED_KEY));
    }

    @Override
    protected void execute() {
    }

    @Override
    protected boolean isFinished() {
        return isTimedOut();
    }

    @Override
    protected void end() {
    }

    @Override
    protected void interrupted() {
    }
}

/*
 * Copyright (c) 2016 RobotsByTheC. All rights reserved.
 *
 * Open Source Software - may be modified and shared by FRC teams. The code must
 * be accompanied by the BSD license file in the root directory of the project.
 */
package org.usfirst.frc.team2084.CMonster2016.commands;

import org.usfirst.frc.team2084.CMonster2016.vision.VisionParameters;

/**
 * Notifies the driver about whether the robot is ready to take a shot. This
 * prints a value on the SmartDashboard.
 *
 * @author Ben Wolsieffer
 */
public class SetCameraAutoExposure extends ParameterCommand {

    public static final String ENABLED_KEY = "Enabled";

    public static final double ENABLE_TIME = 0.3;

    /**
     * Updates the SmartDashboard indicator based on whether the robot is ready
     * to shoot
     *
     * @param ready whether the robot is ready
     */
    public SetCameraAutoExposure(boolean enabled) {
        setRunWhenDisabled(true);
        addBooleanParameter(ENABLED_KEY, enabled);
    }

    @Override
    protected void initialize() {
        boolean enable = getBooleanParameter(ENABLED_KEY);

        if (enable) {
            setTimeout(ENABLE_TIME);
        } else {
            setTimeout(0);
        }

        VisionParameters.setAutoExposure(enable);
    }

    @Override
    protected void execute() {
    }

    @Override
    protected boolean isFinished() {
        return isTimedOut();
    }

    @Override
    protected void end() {
    }

    @Override
    protected void interrupted() {
    }
}

Add delay to camera autoexposure enabling.


package biz.kasual.recyclerfragment.views;

import android.content.Context;
import android.support.v7.widget.CardView;
import android.util.AttributeSet;

/**
 * Created by Stephen Vinouze on 09/11/2015.
 */
public class BasicCardView extends CardView {

    public BasicCardView(Context context) {
        super(context);
        initView();
    }

    public BasicCardView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        initView();
    }

    private void initView() {
        setUseCompatPadding(true);
        setCardElevation(8);
        setRadius(5);
    }

}

package biz.kasual.recyclerfragment.views;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.CardView;
import android.util.AttributeSet;

import biz.kasual.recyclerfragment.R;

/**
 * Created by Stephen Vinouze on 09/11/2015.
 */
public class BasicCardView extends CardView {

    public BasicCardView(Context context) {
        super(context);
        initView();
    }

    public BasicCardView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        initView();
    }

    private void initView() {
        setUseCompatPadding(true);
        setCardElevation(8);
        setRadius(5);

        int[] attrs = new int[] { R.attr.selectableItemBackground};
        TypedArray ta = getContext().obtainStyledAttributes(attrs);
        Drawable drawableFromTheme = ta.getDrawable(0);
        setForeground(drawableFromTheme);
        ta.recycle();
    }

}

Add ripple drawable to cards


/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

package cx2x.translator.common;

/**
 * Contains common constants values of the CLAW XcodeML to XcodeML translator
 *
 * @author clementval
 */
public class ClawConstant {

  public static final String EMPTY_STRING = "";
  public static final String OPENACC_PREFIX = "acc";
  public static final int OPENACC_PREFIX_LENGTH = 6; // "!$acc "
  public static final String CONTINUATION_LINE_SYMBOL = "&";
  public static final String DEFAULT_STEP_VALUE = "1";

  public static final String EXTRACTION_SUFFIX = "_extracted";

  public static final String CLAW_MOD_SUFFIX = ".claw";

  // CLAW atrtibute
  public static final String IS_CLAW = "is_claw";

}

/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

package cx2x.translator.common;

/**
 * Contains common constants values of the CLAW XcodeML to XcodeML translator
 *
 * @author clementval
 */
public class ClawConstant {

  public static final String EMPTY_STRING = "";
  public static final String OPENACC_PREFIX = "acc";
  public static final int OPENACC_PREFIX_LENGTH = 6; // "!$acc "
  public static final String CONTINUATION_LINE_SYMBOL = "&";
  public static final String DEFAULT_STEP_VALUE = "1";
  public static final String DEFUALT_LOWER_BOUND = "1";
  public static final String ITER_PREFIX = "iter_";

  public static final String EXTRACTION_SUFFIX = "_extracted";

  public static final String CLAW_MOD_SUFFIX = ".claw";

  // CLAW atrtibute
  public static final String IS_CLAW = "is_claw";

}

Add constant for induction and lower bound


package com.rwtema.funkylocomotion.network;

import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.server.management.PlayerManager;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;

import java.util.WeakHashMap;

public class FLNetwork {
    public static SimpleNetworkWrapper net;

    public static void init() {
        net = new SimpleNetworkWrapper("FLoco");
        net.registerMessage(MessageClearTile.Handler.class, MessageClearTile.class, 0, Side.SERVER);
        net.registerMessage(MessageClearTile.Handler.class, MessageClearTile.class, 0, Side.CLIENT);
    }

    private static WeakHashMap<World, PlayerManager> cache = new WeakHashMap<World, PlayerManager>();

    public static void sendToAllWatchingChunk(World world, int x, int y, int z, IMessage message) {

        if (!cache.containsKey(world)) {

            if (!(world instanceof WorldServer)) {
                cache.put(world, null);
            } else
                cache.put(world, ((WorldServer) world).getPlayerManager());

        }

        PlayerManager playerManager = cache.get(world);
        if (playerManager == null)
            return;

        PlayerManager.PlayerInstance watcher = playerManager.getOrCreateChunkWatcher(x >> 4, z >> 4, false);
        watcher.sendToAllPlayersWatchingChunk(net.getPacketFrom(message));
    }
}

package com.rwtema.funkylocomotion.network;

import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.server.management.PlayerManager;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;

import java.util.WeakHashMap;

public class FLNetwork {
    public static SimpleNetworkWrapper net;

    public static void init() {
        net = new SimpleNetworkWrapper("FLoco");
        net.registerMessage(MessageClearTile.Handler.class, MessageClearTile.class, 0, Side.SERVER);
        net.registerMessage(MessageClearTile.Handler.class, MessageClearTile.class, 0, Side.CLIENT);
    }

    private static WeakHashMap<World, PlayerManager> cache = new WeakHashMap<World, PlayerManager>();

    public static void sendToAllWatchingChunk(World world, int x, int y, int z, IMessage message) {

        if (!cache.containsKey(world)) {
            if (!(world instanceof WorldServer)) {
                cache.put(world, null);
            } else
                cache.put(world, ((WorldServer) world).getPlayerManager());
        }

        PlayerManager playerManager = cache.get(world);
        if (playerManager == null)
            return;

        PlayerManager.PlayerInstance watcher = playerManager.getOrCreateChunkWatcher(x >> 4, z >> 4, false);
        if (watcher != null)
            watcher.sendToAllPlayersWatchingChunk(net.getPacketFrom(message));
    }
}

Fix crash when frames are moving in chunks without nearby players.


/**
 * $LastChangedRevision$
 * $HeadURL$
 * $LastChangedDate$
 * $LastChangedBy$
 */
package net.sf.cafemocha.application.swing;

import net.sf.cafemocha.application.Application;

/**
 * A simple application lifecycle for a Swing application.
 *
 * @author computerguy5
 *
 */
public class SwingApplication extends Application {

	// TODO Add Look and Feel, Window location preferences, etc.

}

/**
 * $LastChangedRevision$
 * $HeadURL$
 * $LastChangedDate$
 * $LastChangedBy$
 */
package net.sf.cafemocha.application.swing;

import net.sf.cafemocha.application.Application;

/**
 * A simple application lifecycle for a Swing application.
 *
 * @author computerguy5
 *
 */
public class SwingApplication extends Application {

	/*
	 * Convenience method that returns the covariant SwingApplicationContext.
	 *
	 * @see net.sf.cafemocha.application.Application#getContext()
	 */
	@Override
	public SwingApplicationContext getContext() {
		// TODO Enforce safety of cast through constructor
		return (SwingApplicationContext) super.getContext();
	}

	// TODO Add Look and Feel, Window location preferences, etc.

}

Set keywords on all existing Java files.


package com.github.davidmoten.rx;

import rx.Scheduler;

public final class Schedulers {

    public static Scheduler computation(String id) {
        return new SchedulerWithId(rx.schedulers.Schedulers.computation(), id);
    }

    public static Scheduler computation() {
        return withId(rx.schedulers.Schedulers.computation());
    }

    private static Scheduler withId(Scheduler scheduler) {
        return new SchedulerWithId(Schedulers.computation(), describeCallSite());
    }

    private static String describeCallSite() {
        StackTraceElement[] elements = Thread.currentThread().getStackTrace();
        StackTraceElement e = elements[3];
        return e.getClassName() + ":" + e.getMethodName() + ":" + e.getLineNumber();
    }

    private static void doIt() {
        System.out.println(describeCallSite());
    }

    public static void main(String[] args) {
        doIt();
    }
}

package com.github.davidmoten.rx;

import rx.Scheduler;

public final class Schedulers {

    public static Scheduler computation(String id) {
        return new SchedulerWithId(rx.schedulers.Schedulers.computation(), id);
    }

    public static Scheduler computation() {
        return withId(rx.schedulers.Schedulers.computation());
    }

    private static Scheduler withId(Scheduler scheduler) {
        return new SchedulerWithId(scheduler, describeCallSite());
    }

    private static String describeCallSite() {
        StackTraceElement[] elements = Thread.currentThread().getStackTrace();
        StackTraceElement e = elements[3];
        return e.getClassName() + ":" + e.getMethodName() + ":" + e.getLineNumber();
    }

    private static void doIt() {
        System.out.println(describeCallSite());
    }

    public static void main(String[] args) {
        doIt();
    }
}

Update withId to use the passed parameter


package org.ndexbio.model.object.network;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Namespace extends NetworkElement
{
    private String _prefix;
    private String _uri;

    /**************************************************************************
    * Default constructor.
    **************************************************************************/
    public Namespace()
    {
        super();
        _type = this.getClass().getSimpleName();
    }

    public String getPrefix()
    {
        return _prefix;
    }

    public void setPrefix(String prefix) //throws Exception
    {
//    	if ( prefix == null ) throw new Exception("Prefix for Namespace can't be null.");
        _prefix = prefix;
    }

    public String getUri()
    {
        return _uri;
    }

    public void setUri(String uri)
    {
        _uri = uri;
    }
}

package org.ndexbio.model.object.network;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Namespace extends PropertiedNetworkElement
{
    private String _prefix;
    private String _uri;

    /**************************************************************************
    * Default constructor.
    **************************************************************************/
    public Namespace()
    {
        super();
        _type = this.getClass().getSimpleName();
    }

    public String getPrefix()
    {
        return _prefix;
    }

    public void setPrefix(String prefix) //throws Exception
    {
//    	if ( prefix == null ) throw new Exception("Prefix for Namespace can't be null.");
        _prefix = prefix;
    }

    public String getUri()
    {
        return _uri;
    }

    public void setUri(String uri)
    {
        _uri = uri;
    }
}

Extend namespace class from PropertiedNetworkElement.


package net.simpvp.Events;

import java.util.UUID;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;

public class PluginDisable implements Listener {

	@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
	public void onPlayerQuit(PluginDisableEvent event) {
		for (Player p : Events.instance.getServer().getOnlinePlayers()) {
			UUID uuid = p.getUniqueId();
			if (!Event.isPlayerActive(uuid)) {
				return;
			}

			EventPlayer eventPlayer = Event.getEventPlayer(uuid);
			eventPlayer.sendHome(p);
			p.teleport(eventPlayer.getLocation());
		}
	}
}

package net.simpvp.Events;

import java.util.UUID;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;

public class PluginDisable implements Listener {

	@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
	public void onPlayerQuit(PluginDisableEvent event) {
		for (Player p : Events.instance.getServer().getOnlinePlayers()) {
			UUID uuid = p.getUniqueId();
			if (!Event.isPlayerActive(uuid)) {
				continue;
			}

			EventPlayer eventPlayer = Event.getEventPlayer(uuid);
			eventPlayer.sendHome(p);
			p.teleport(eventPlayer.getLocation());
		}
	}
}

Fix wrong return -> continue


package fault.metrics;

import fault.concurrent.LongAdder;

/**
 * Created by timbrooks on 6/1/15.
 */
public class Second {

    private final LongAdder successes = new LongAdder();
    private final LongAdder errors = new LongAdder();
    private final LongAdder timeouts = new LongAdder();
    private final LongAdder circuitOpen = new LongAdder();
    private final LongAdder queueFull = new LongAdder();
    private final LongAdder maxConcurrencyExceeded = new LongAdder();
}

package fault.metrics;

import fault.concurrent.LongAdder;

/**
 * Created by timbrooks on 6/1/15.
 */
public class Second {

    private final LongAdder successes = new LongAdder();
    private final LongAdder errors = new LongAdder();
    private final LongAdder timeouts = new LongAdder();
    private final LongAdder circuitOpen = new LongAdder();
    private final LongAdder queueFull = new LongAdder();
    private final LongAdder maxConcurrencyExceeded = new LongAdder();

    public void incrementMetric(Metric metric) {
        switch (metric) {
            case SUCCESS:
                successes.increment();
                break;
            case ERROR:
                errors.increment();
                break;
            case TIMEOUT:
                timeouts.increment();
                break;
            case CIRCUIT_OPEN:
                circuitOpen.increment();
                break;
            case QUEUE_FULL:
                queueFull.increment();
                break;
            case MAX_CONCURRENCY_LEVEL_EXCEEDED:
                maxConcurrencyExceeded.increment();
                break;
            default:
                throw new RuntimeException("Unknown metric: " + metric);
        }
    }
}

Add method to increment metrics


package com.fsck.k9.message.html;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.safety.Cleaner;
import org.jsoup.safety.Whitelist;

public class HtmlSanitizer {
    private final HeadCleaner headCleaner;
    private final Cleaner cleaner;

    HtmlSanitizer() {
        Whitelist whitelist = Whitelist.relaxed()
                .addTags("font", "hr", "ins", "del")
                .addAttributes("table", "align", "bgcolor", "border", "cellpadding", "cellspacing", "width")
                .addAttributes("tr", "align", "bgcolor", "valign")
                .addAttributes("th",
                        "align", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "sorted",
                        "valign", "width")
                .addAttributes("td",
                        "align", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign",
                        "width")
                .addAttributes(":all", "class", "style", "id")
                .addProtocols("img", "src", "http", "https", "cid", "data");

        cleaner = new Cleaner(whitelist);
        headCleaner = new HeadCleaner();
    }

    public Document sanitize(String html) {
        Document dirtyDocument = Jsoup.parse(html);
        Document cleanedDocument = cleaner.clean(dirtyDocument);
        headCleaner.clean(dirtyDocument, cleanedDocument);
        return cleanedDocument;
    }
}

package com.fsck.k9.message.html;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.safety.Cleaner;
import org.jsoup.safety.Whitelist;

public class HtmlSanitizer {
    private final HeadCleaner headCleaner;
    private final Cleaner cleaner;

    HtmlSanitizer() {
        Whitelist whitelist = Whitelist.relaxed()
                .addTags("font", "hr", "ins", "del")
                .addAttributes("table", "align", "background", "bgcolor", "border", "cellpadding", "cellspacing",
                        "width")
                .addAttributes("tr", "align", "bgcolor", "valign")
                .addAttributes("th",
                        "align", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "sorted",
                        "valign", "width")
                .addAttributes("td",
                        "align", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign",
                        "width")
                .addAttributes(":all", "class", "style", "id")
                .addProtocols("img", "src", "http", "https", "cid", "data");

        cleaner = new Cleaner(whitelist);
        headCleaner = new HeadCleaner();
    }

    public Document sanitize(String html) {
        Document dirtyDocument = Jsoup.parse(html);
        Document cleanedDocument = cleaner.clean(dirtyDocument);
        headCleaner.clean(dirtyDocument, cleanedDocument);
        return cleanedDocument;
    }
}

Add 'background' attribute for 'table' tag to the whitelist


package gui;

import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;

import controller.Controller;

public class PasswordPane
{
	public static String showUnlockWalletDialog()
	{
		JPanel userPanel = new JPanel();
		userPanel.setLayout(new GridLayout(2,2));

		//Labels for the textfield components
		JLabel passwordLbl = new JLabel("Enter wallet password:");
		JPasswordField passwordFld = new JPasswordField();

		//Add the components to the JPanel
		userPanel.add(passwordLbl);
		userPanel.add(passwordFld);

		Object[] options = {"Unlock",
                "Unlock for 2 minutes",
                "Cancel"};

		//As the JOptionPane accepts an object as the message
		//it allows us to use any component we like - in this case
		//a JPanel containing the dialog components we want

		int n = JOptionPane.showOptionDialog(
					null,
					userPanel,
					"Unlock Wallet",
					JOptionPane.YES_NO_CANCEL_OPTION,
					JOptionPane.QUESTION_MESSAGE,
					null,
					options,
					options[2]
				);

		if(n == JOptionPane.YES_OPTION) {
			Controller.getInstance().setSecondsToUnlock(-1);
		} else if (n == JOptionPane.NO_OPTION) {
			Controller.getInstance().setSecondsToUnlock(120);
		} else {
			return "";
		}

		return new String(passwordFld.getPassword());
	}
}

package gui;

import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;

import controller.Controller;

public class PasswordPane
{
	public static String showUnlockWalletDialog()
	{
		JPanel userPanel = new JPanel();
		userPanel.setLayout(new GridLayout(2,2));

		//Labels for the textfield components
		JLabel passwordLbl = new JLabel("Enter wallet password:");
		JPasswordField passwordFld = new JPasswordField();

		//Add the components to the JPanel
		userPanel.add(passwordLbl);
		userPanel.add(passwordFld);

		Object[] options = {"Unlock",
                "Unlock for 2 minutes",
                "Cancel"};

		//As the JOptionPane accepts an object as the message
		//it allows us to use any component we like - in this case
		//a JPanel containing the dialog components we want

		int n = JOptionPane.showOptionDialog(
					null,
					userPanel,
					"Unlock Wallet",
					JOptionPane.YES_NO_CANCEL_OPTION,
					JOptionPane.QUESTION_MESSAGE,
					null,
					options,
					passwordFld
				);

		if(n == JOptionPane.YES_OPTION) {
			Controller.getInstance().setSecondsToUnlock(-1);
		} else if (n == JOptionPane.NO_OPTION) {
			Controller.getInstance().setSecondsToUnlock(120);
		} else {
			return "";
		}

		return new String(passwordFld.getPassword());
	}
}

Set default selection to password


package org.cafebabepy.runtime.object;

import org.cafebabepy.runtime.PyObject;
import org.cafebabepy.runtime.Python;

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

/**
 * Created by yotchang4s on 2017/06/19.
 */
public class PyTupleObject extends AbstractPyObjectObject {

    private final List<PyObject> list;

    public PyTupleObject(Python runtime, PyObject... value) {
        super(runtime, runtime.typeOrThrow("builtins.list"));

        this.list = Collections.unmodifiableList(Arrays.asList(value));
    }

    public List<PyObject> getList() {
        return this.list;
    }

    public PyObject get(PyIntObject i) {
        return this.list.get(i.getIntValue());
    }

    public PyObject getLen() {
        return this.runtime.number(list.size());
    }

    @Override
    public String asJavaString() {
        return this.list.stream()
                .map(PyObject::asJavaString)
                .collect(Collectors.joining(",", "(", ")"));
    }
}

package org.cafebabepy.runtime.object;

import org.cafebabepy.runtime.PyObject;
import org.cafebabepy.runtime.Python;

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

/**
 * Created by yotchang4s on 2017/06/19.
 */
public class PyTupleObject extends AbstractPyObjectObject {

    private final List<PyObject> list;

    public PyTupleObject(Python runtime, PyObject... value) {
        super(runtime, runtime.typeOrThrow("builtins.tuple"));

        this.list = Collections.unmodifiableList(Arrays.asList(value));
    }

    public List<PyObject> getList() {
        return this.list;
    }

    public PyObject get(PyIntObject i) {
        return this.list.get(i.getIntValue());
    }

    public PyObject getLen() {
        return this.runtime.number(list.size());
    }

    @Override
    public String asJavaString() {
        return this.list.stream()
                .map(PyObject::asJavaString)
                .collect(Collectors.joining(",", "(", ")"));
    }
}

Fix list to tuple type


package org.msf.records.model;

import java.io.Serializable;

/**
 * Created by Gil on 03/10/2014.
 */
public class Patient implements Serializable {

    public String id;
    public String given_name;
    public String family_name;

    public String important_information;

    /**
     * Accepted values:
     * suspected, probable, confirmed, non-case, convalescent,
     * can_be_discharged, dischraged, suspected_dead, confirmed_dead
     */
    public String status;

    public boolean pregnant;

    // Must be "M" or "F".
    public String gender;

    @Deprecated
    public String movement;
    @Deprecated
    public String eating;

    public Long admission_timestamp;
    public Long created_timestamp;
    public Long first_showed_symptoms_timestamp;

    public String origin_location;
    // Not yet ready.
    public String next_of_kin;

    public PatientLocation assigned_location;
    public PatientAge age;

}

package org.msf.records.model;

import java.io.Serializable;

/**
 * Created by Gil on 03/10/2014.
 */
public class Patient implements Serializable {

    public String id;
    public String uuid;
    public String given_name;
    public String family_name;

    public String important_information;

    /**
     * Accepted values:
     * suspected, probable, confirmed, non-case, convalescent,
     * can_be_discharged, dischraged, suspected_dead, confirmed_dead
     */
    public String status;

    public boolean pregnant;

    // Must be "M" or "F".
    public String gender;

    @Deprecated
    public String movement;
    @Deprecated
    public String eating;

    public Long admission_timestamp;
    public Long created_timestamp;
    public Long first_showed_symptoms_timestamp;

    public String origin_location;
    // Not yet ready.
    public String next_of_kin;

    public PatientLocation assigned_location;
    public PatientAge age;

}

Add uuid to the patient bean in Android


package com.github.tomakehurst.wiremock.admin;

import com.github.tomakehurst.wiremock.admin.model.ResponseDefinitionBodyMatcher;
import com.github.tomakehurst.wiremock.http.ResponseDefinition;
import org.junit.Test;

import static com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder.responseDefinition;
import static junit.framework.TestCase.assertFalse;

public class ResponseDefinitionBodyMatcherTest {
    @Test
    public void doesNotMatchEmptyBody() {
        ResponseDefinition emptyBody = responseDefinition().build();
        ResponseDefinitionBodyMatcher matcher = new ResponseDefinitionBodyMatcher(0, 0);
        assertFalse(matcher.match(emptyBody).isExactMatch());
    }
}

package com.github.tomakehurst.wiremock.admin;

import com.github.tomakehurst.wiremock.admin.model.ResponseDefinitionBodyMatcher;
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
import com.github.tomakehurst.wiremock.http.ResponseDefinition;
import org.junit.Test;

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

public class ResponseDefinitionBodyMatcherTest {
    @Test
    public void noThresholds() {
        ResponseDefinitionBodyMatcher matcher = new ResponseDefinitionBodyMatcher(0, 0);
        assertFalse(matcher.match(new ResponseDefinition()).isExactMatch());
        assertTrue(matcher.match(textResponseDefinition("a")).isExactMatch());
        assertTrue(matcher.match(binaryResponseDefinition(new byte[] { 0x1 })).isExactMatch());
    }

    @Test
    public void textBodyMatchingWithThreshold() {
        ResponseDefinitionBodyMatcher matcher = new ResponseDefinitionBodyMatcher(2, 0);
        assertFalse(matcher.match(textResponseDefinition("f")).isExactMatch());
        assertFalse(matcher.match(textResponseDefinition("fo")).isExactMatch());
        assertTrue(matcher.match(textResponseDefinition("foo")).isExactMatch());
    }

    @Test
    public void binaryBodyMatchingWithThreshold() {
        ResponseDefinitionBodyMatcher matcher = new ResponseDefinitionBodyMatcher(0, 2);
        assertFalse(matcher.match(binaryResponseDefinition(new byte[] { 0x1 })).isExactMatch());
        assertFalse(matcher.match(binaryResponseDefinition(new byte[] { 0x1, 0xc })).isExactMatch());
        assertTrue(matcher.match(binaryResponseDefinition(new byte[] { 0x1, 0xc, 0xf })).isExactMatch());
    }

    private static ResponseDefinition textResponseDefinition(String body) {
        return new ResponseDefinitionBuilder()
            .withHeader("Content-Type", "text/plain")
            .withBody(body)
            .build();
    }

    private static ResponseDefinition binaryResponseDefinition(byte[] body) {
        return new ResponseDefinitionBuilder()
            .withBody(body)
            .build();
    }
}

Add more tests for ResponseDefinitionBodyMatcher


package com.grailbox.twicket;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.validation.validator.StringValidator.MinimumLengthValidator;

public class SearchPanel extends Panel {
  private static final long serialVersionUID = -8610733111417498232L;

  public SearchPanel(String id) {
    super(id);
    add(new SearchForm("searchForm"));
  }

  private class SearchForm extends StatelessForm<SearchParams> {
    private static final long serialVersionUID = -5253297831508495384L;

    private SearchForm(final String id) {
      super(id);
      setModel(new CompoundPropertyModel<SearchParams>(new SearchParams()));
      add(new Label("searchLabel", "Search Terms:"));
      add(new TextField<String>("searchString").setRequired(true).add(new MinimumLengthValidator(3)));
    }

    @Override
    protected final void onSubmit() {
      SearchParams params = getModelObject();
      if (params != null) {
        setResponsePage(new HomePage(new SearchTweetRetriever(params)));
      }
    }
  }
}

package com.grailbox.twicket;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.validation.validator.StringValidator.MinimumLengthValidator;

public class SearchPanel extends Panel {
  private static final long serialVersionUID = -8610733111417498232L;

  public SearchPanel(String id) {
    super(id);
    add(new SearchForm("searchForm"));
  }

  private class SearchForm extends StatelessForm<SearchParams> {
    private static final long serialVersionUID = -5253297831508495384L;

    private SearchForm(final String id) {
      super(id);
      setModel(new CompoundPropertyModel<SearchParams>(new SearchParams()));
      add(new Label("searchLabel", "Search Terms:"));
      add(new TextField<String>("searchString").setRequired(true).add(new MinimumLengthValidator(3)));
    }

    @Override
    protected final void onSubmit() {
      setResponsePage(new HomePage(new SearchTweetRetriever(getModelObject())));
    }
  }
}

Remove check for null params in onSubmit


package com.mssngvwls;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;

@Service
public class GamePhraseSelector {

    private final PhraseRepository phraseRepository;
    private final PhraseFormatter phraseFormatter;

    public GamePhraseSelector(final PhraseRepository phraseRepository, final PhraseFormatter phraseFormatter) {
        this.phraseRepository = phraseRepository;
        this.phraseFormatter = phraseFormatter;
    }

    public Queue<GamePhrase> generateCategories() {
        final List<Phrase> phrases = phraseRepository.getPhrases();
        Collections.shuffle(phrases);
        return phrases.stream()
                .limit(10)
                .map(phrase -> new GamePhrase(phrase.getFullPhrase(), phraseFormatter.format(phrase.getFullPhrase()), phrase.getCategory().getName()))
                .collect(Collectors.toCollection(LinkedList::new));
    }

}

package com.mssngvwls;

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

import org.springframework.stereotype.Service;

@Service
public class GamePhraseSelector {

    private final CategoryRepository categoryRepository;
    private final PhraseFormatter phraseFormatter;

    public GamePhraseSelector(final CategoryRepository categoryRepository, final PhraseFormatter phraseFormatter) {
        this.categoryRepository = categoryRepository;
        this.phraseFormatter = phraseFormatter;
    }

    public Queue<GamePhrase> generateCategories(final int numberOfCategories, final int numberOfPhrasesPerCategory) {
        final List<Category> categories = categoryRepository.getAllCategories();

        return categories.stream()
                .filter(category -> category.getPhrases().size() >= numberOfPhrasesPerCategory)
                .limit(numberOfCategories)
                .map(Category::getPhrases)
                .limit(numberOfPhrasesPerCategory)
                .flatMap(List::stream)
                .map(phrase -> new GamePhrase(phrase.getFullPhrase(), phraseFormatter.format(phrase.getFullPhrase()), phrase.getCategory().getName()))
                .collect(Collectors.toCollection(LinkedList::new));
    }

}

Change how game phrases are generated - more streams!


package org.pentaho.ui.xul.swing.tags;

import java.awt.GridBagLayout;
import java.util.ArrayList;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;

import org.pentaho.ui.xul.XulComponent;
import org.pentaho.ui.xul.XulDomContainer;
import org.pentaho.ui.xul.containers.XulMenubar;
import org.pentaho.ui.xul.swing.SwingElement;

public class SwingMenubar extends SwingElement implements XulMenubar{

  private JMenuBar menuBar;
  public SwingMenubar(XulComponent parent, XulDomContainer domContainer, String tagName) {
    super("menubar");

    children = new ArrayList<XulComponent>();

    menuBar = new JMenuBar();
    managedObject = menuBar;

  }

  @Override
  public void layout(){
    for(XulComponent comp : children){
      if(comp instanceof SwingMenu){
        this.menuBar.add((JMenu) ((SwingMenu) comp).getManagedObject());
      }
    }
  }

}

package org.pentaho.ui.xul.swing.tags;

import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.util.ArrayList;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;

import org.pentaho.ui.xul.XulComponent;
import org.pentaho.ui.xul.XulDomContainer;
import org.pentaho.ui.xul.containers.XulMenubar;
import org.pentaho.ui.xul.swing.SwingElement;

public class SwingMenubar extends SwingElement implements XulMenubar{

  private JMenuBar menuBar;
  public SwingMenubar(XulComponent parent, XulDomContainer domContainer, String tagName) {
    super("menubar");

    children = new ArrayList<XulComponent>();

    menuBar = new JMenuBar();
    menuBar.setMinimumSize(new Dimension(20,20));
    managedObject = menuBar;

  }

  @Override
  public void layout(){
    for(XulComponent comp : children){
      if(comp instanceof SwingMenu){
        this.menuBar.add((JMenu) ((SwingMenu) comp).getManagedObject());
      }
    }
  }

}

Set a minimum height to prevent the menu from surrendering it's entire space


/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2016 Vincent Zhang/PhoenixLAB
 *
 * 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 co.phoenixlab.discord.api.endpoints;

public interface AuthenticationEndpoint {

}

/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2016 Vincent Zhang/PhoenixLAB
 *
 * 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 co.phoenixlab.discord.api.endpoints;

import co.phoenixlab.discord.api.entities.TokenResponse;
import co.phoenixlab.discord.api.request.EmailPasswordLoginRequest;
import co.phoenixlab.discord.api.request.LogoutRequest;

public interface AuthenticationEndpoint {

    TokenResponse logIn(EmailPasswordLoginRequest request)
            throws ApiException;

    void logOut(LogoutRequest request)
            throws ApiException;

}

Add methods to Auth endpoint


/*
 * Copyright 2016 Hippo Seven
 *
 * 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.hippo.ehviewer.client;

public class EhCacheKeyFactory {

    public static String getThumbKey(long gid) {
        return "thumb:" + gid;
    }

    public static String getNormalPreviewKey(long gid, int index) {
        return "preview:normal:" + gid + ":" + index;
    }

    public static String getLargePreviewKey(long gid, int index) {
        return "preview:large:" + gid + ":" + index;
    }

    public static String getLargePreviewSetKey(long gid, int index) {
        return "large_preview_set:" + gid + ":" + index;
    }

    public static String getImageKey(long gid, int index) {
        return "image:" + gid + ":" + index;
    }
}

/*
 * Copyright 2016 Hippo Seven
 *
 * 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.hippo.ehviewer.client;

public class EhCacheKeyFactory {

    public static String getThumbKey(long gid) {
        return "preview:large:" + gid + ":" + 0; // "thumb:" + gid;
    }

    public static String getNormalPreviewKey(long gid, int index) {
        return "preview:normal:" + gid + ":" + index;
    }

    public static String getLargePreviewKey(long gid, int index) {
        return "preview:large:" + gid + ":" + index;
    }

    public static String getLargePreviewSetKey(long gid, int index) {
        return "large_preview_set:" + gid + ":" + index;
    }

    public static String getImageKey(long gid, int index) {
        return "image:" + gid + ":" + index;
    }
}

Make thumb cache key as first large preview cache key


//@author A0116538A

package bakatxt.gui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;

import bakatxt.core.Task;

/**
 * This class dictates the color and shape of the box which the task will be put in.
 * This box is specifically for a top most box.
 *
 */
class FirstTaskBox extends TaskBox {

    public FirstTaskBox(Task task, Color backgroundColor) {
        super(task, backgroundColor);
    }

    @Override
    protected void paintComponent(Graphics g) {
        Graphics2D g2d = (Graphics2D) g.create();
        g2d.setColor(getBackground());
        g2d.setRenderingHints(UIHelper.antiAlias());
        g2d.fill(new TopRounded(getWidth(), getHeight()));
        g2d.dispose();
        super.paintComponent(g);
    }

    // TODO fix topRounded method
    class TopRounded extends Path2D.Double {

        public TopRounded(double width, double height) {
            moveTo(0, 0);
            lineTo(width, 0);
            lineTo(width, height - UIHelper.WINDOW_ROUNDNESS);
            curveTo(width, height, width, height, width - UIHelper.WINDOW_ROUNDNESS, height);
            lineTo(UIHelper.WINDOW_ROUNDNESS, height);
            curveTo(0, height, 0, height, 0, height - UIHelper.WINDOW_ROUNDNESS);
            lineTo(0, 0);
            closePath();
        }
    }
}

//@author A0116538A

package bakatxt.gui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;

import bakatxt.core.Task;

/**
 * This class dictates the color and shape of the box which the task will be put in.
 * This box is specifically for a top most box.
 *
 */
class FirstTaskBox extends TaskBox {

    public FirstTaskBox(Task task, Color backgroundColor) {
        super(task, backgroundColor);
    }

    @Override
    protected void paintComponent(Graphics g) {
        Graphics2D g2d = (Graphics2D) g.create();
        g2d.setColor(getBackground());
        g2d.setRenderingHints(UIHelper.antiAlias());
        g2d.fill(new TopRounded(getWidth(), getHeight()));
        g2d.dispose();
        super.paintComponent(g);
    }

    class TopRounded extends Path2D.Double {

        public TopRounded(double width, double height) {
            moveTo(0, height);
            lineTo(0, UIHelper.WINDOW_ROUNDNESS);
            curveTo(0, 0, 0, 0, UIHelper.WINDOW_ROUNDNESS, 0);
            lineTo(width - UIHelper.WINDOW_ROUNDNESS, 0);
            curveTo(width, 0, width, 0, width, UIHelper.WINDOW_ROUNDNESS);
            lineTo(width, height);
            lineTo(0, height);
            closePath();
        }
    }
}

Fix topRounded method to draw the correct shape


package com.laytonsmith.abstraction.enums;

import com.laytonsmith.annotations.MEnum;

/**
 * A MCItemFlag can hide some Attributes from MCItemStacks, through MCItemMeta.
 */
@MEnum("com.commandhelper.ItemFlag")
public enum MCItemFlag {
	/**
	 * Setting to show/hide enchants
	 */
	HIDE_ENCHANTS,
	/**
	 * Setting to show/hide Attributes like Damage
	 */
	HIDE_ATTRIBUTES,
	/**
	 * Setting to show/hide the unbreakable State
	 */
	HIDE_UNBREAKABLE,
	/**
	 * Setting to show/hide what the ItemStack can break/destroy
	 */
	HIDE_DESTROYS,
	/**
	 * Setting to show/hide where this ItemStack can be build/placed on
	 */
	HIDE_PLACED_ON,
	/**
	 * Setting to show/hide potion effects on this ItemStack
	 */
	HIDE_POTION_EFFECTS;
}

package com.laytonsmith.abstraction.enums;

import com.laytonsmith.annotations.MEnum;

/**
 * A MCItemFlag can hide some Attributes from MCItemStacks, through MCItemMeta.
 */
@MEnum("com.commandhelper.ItemFlag")
public enum MCItemFlag {
	/**
	 * Setting to show/hide enchants
	 */
	HIDE_ENCHANTS,
	/**
	 * Setting to show/hide Attributes like Damage
	 */
	HIDE_ATTRIBUTES,
	/**
	 * Setting to show/hide the unbreakable State
	 */
	HIDE_UNBREAKABLE,
	/**
	 * Setting to show/hide what the ItemStack can break/destroy
	 */
	HIDE_DESTROYS,
	/**
	 * Setting to show/hide where this ItemStack can be build/placed on
	 */
	HIDE_PLACED_ON,
	/**
	 * Setting to show/hide potion effects on this ItemStack
	 */
	HIDE_POTION_EFFECTS,
	/**
	 * Setting to show/hide dyes from coloured leather armour
	 */
	HIDE_DYE;
}

Add HIDE_DYE item meta flag


/*
 * 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.tuentitv.ui.util;

import android.content.Context;

/**
 * @author Pedro Vicente Gómez Sánchez.
 */
public class Util {

  public static int convertDpToPixel(Context context, int dp) {
    float density = context.getResources().getDisplayMetrics().density;
    return Math.round((float) dp * density);
  }
}

Add copyright header to util package


package org.commcare.util.externalizable;

import org.javarosa.core.util.externalizable.Hasher;
import org.javarosa.core.util.externalizable.PrototypeFactory;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author ctsims
 */
public class AndroidClassHasher extends Hasher {

    private static final int CLASS_HASH_SIZE = 4;

    MessageDigest mMessageDigester;

    public AndroidClassHasher() {
        try {
            mMessageDigester = java.security.MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static void registerAndroidClassHashStrategy() {
        PrototypeFactory.setStaticHasher(new AndroidClassHasher());
    }

    public byte[] getHash(Class c){
        byte[] ret;
        synchronized(mMessageDigester) {
            ret = mMessageDigester.digest(c.getName().getBytes());
        }
        return ret;
    }

    @Override
    public int getHashSize(){
        return CLASS_HASH_SIZE;
    }

}

package org.commcare.util.externalizable;

import org.javarosa.core.util.externalizable.Hasher;
import org.javarosa.core.util.externalizable.PrototypeFactory;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author ctsims
 */
public class AndroidClassHasher extends Hasher {

    private static final int CLASS_HASH_SIZE = 4;

    private final MessageDigest mMessageDigester;

    public AndroidClassHasher() {
        try {
            mMessageDigester = java.security.MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }

    public static void registerAndroidClassHashStrategy() {
        PrototypeFactory.setStaticHasher(new AndroidClassHasher());
    }

    public byte[] getHash(Class c){
        byte[] ret;
        synchronized(mMessageDigester) {
            ret = mMessageDigester.digest(c.getName().getBytes());
        }
        return ret;
    }

    @Override
    public int getHashSize(){
        return CLASS_HASH_SIZE;
    }
}

Raise runtime exception on unfound hasher method


package greendroid.util;

/**
 * Utility class containing several useful constants related to time.
 *
 * @author Cyril Mottier
 */
public class Time {

	/**
	 * The number of milliseconds in a second.
	 */
	public static final int GD_SECOND = 1000;

	/**
	 * The number of milliseconds in a minute.
	 */
	public static final int GD_MINUTE = GD_SECOND * 60;

	/**
	 * The number of milliseconds in an hour.
	 */
	public static final int GD_HOUR = GD_MINUTE * 60;

	/**
	 * The number of milliseconds in a day.
	 */
	public static final int GD_DAY = GD_HOUR * 24;

	/**
	 * The number of milliseconds in a week.
	 */
	public static final int GD_WEEK = GD_DAY * 7;

}

package greendroid.util;

/**
 * Utility class containing several useful constants related to time.
 *
 * @author Cyril Mottier
 */
public class Time {

	/**
	 * The number of milliseconds in a second.
	 */
	public static final long GD_SECOND = 1000;

	/**
	 * The number of milliseconds in a minute.
	 */
	public static final long GD_MINUTE = GD_SECOND * 60;

	/**
	 * The number of milliseconds in an hour.
	 */
	public static final long GD_HOUR = GD_MINUTE * 60;

	/**
	 * The number of milliseconds in a day.
	 */
	public static final long GD_DAY = GD_HOUR * 24;

	/**
	 * The number of milliseconds in a week.
	 */
	public static final long GD_WEEK = GD_DAY * 7;

}

Use longs for time related constants


/*
 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and contributors.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * Contributors:
 *     Olivier Grisel <ogrisel@nuxeo.com>
 *     Antoine Taillefer <ataillefer@nuxeo.com>
 */
package org.nuxeo.drive.service;

import java.io.Serializable;

public final class NuxeoDriveEvents {

    private NuxeoDriveEvents() {
        // Utility class
    }

    public static final String ABOUT_TO_REGISTER_ROOT = "aboutToRegisterRoot";

    public static final String ROOT_REGISTERED = "rootRegistered";

    public static final String ABOUT_TO_UNREGISTER_ROOT = "aboutToUnRegisterRoot";

    public static final String ROOT_UNREGISTERED = "rootUnregistered";

    public static final String IMPACTED_USERNAME_PROPERTY = "impactedUserName";

    public static final Serializable EVENT_CATEGORY = "NuxeoDrive";

    public static final String DELETED_EVENT = "deleted";

}

/*
 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and contributors.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * Contributors:
 *     Olivier Grisel <ogrisel@nuxeo.com>
 *     Antoine Taillefer <ataillefer@nuxeo.com>
 */
package org.nuxeo.drive.service;

import java.io.Serializable;

/**
 *
 * Core event related constants for Nuxeo Drive.
 *
 * @author Antoine Taillefer
 */
public final class NuxeoDriveEvents {

    private NuxeoDriveEvents() {
        // Utility class
    }

    public static final String ABOUT_TO_REGISTER_ROOT = "aboutToRegisterRoot";

    public static final String ROOT_REGISTERED = "rootRegistered";

    public static final String ABOUT_TO_UNREGISTER_ROOT = "aboutToUnRegisterRoot";

    public static final String ROOT_UNREGISTERED = "rootUnregistered";

    public static final String IMPACTED_USERNAME_PROPERTY = "impactedUserName";

    public static final Serializable EVENT_CATEGORY = "NuxeoDrive";

    public static final String DELETED_EVENT = "deleted";

}

Fix Sonar Major violations: Javadoc Type


/*
 * Copyright 2012 The Netty Project
 *
 * The Netty Project 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 io.netty.channel;

import java.util.concurrent.ThreadFactory;

public abstract class MultithreadEventLoop extends MultithreadEventExecutor implements EventLoop {

    protected MultithreadEventLoop(int nThreads, ThreadFactory threadFactory,
            Object... args) {
        super(nThreads, threadFactory, args);
    }

    @Override
    protected abstract EventExecutor newChild(ThreadFactory threadFactory, Object... args) throws Exception;

    @Override
    public ChannelFuture register(Channel channel) {
        return ((EventLoop) unsafe().nextChild()).register(channel);
    }

    @Override
    public ChannelFuture register(Channel channel, ChannelFuture future) {
        return ((EventLoop) unsafe().nextChild()).register(channel, future);
    }
}

/*
 * Copyright 2012 The Netty Project
 *
 * The Netty Project 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 io.netty.channel;

import java.util.concurrent.ThreadFactory;

public abstract class MultithreadEventLoop extends MultithreadEventExecutor implements EventLoop {

    protected MultithreadEventLoop(int nThreads, ThreadFactory threadFactory,
            Object... args) {
        super(nThreads, threadFactory, args);
    }

    @Override
    public ChannelFuture register(Channel channel) {
        return ((EventLoop) unsafe().nextChild()).register(channel);
    }

    @Override
    public ChannelFuture register(Channel channel, ChannelFuture future) {
        return ((EventLoop) unsafe().nextChild()).register(channel, future);
    }
}

Remove a redundant method declaration


package uk.ac.ebi.quickgo.index.annotation.coterms;

import java.util.Iterator;
import org.springframework.batch.item.ItemReader;

/**
 * Provide a list of all GO Terms for which co-occurrence has been determined ( which is all of them that have been
 * processed, since at worst a GO Term will have a statistic for co-occurring with itself).
 *
 * @author Tony Wardell
 * Date: 07/09/2016
 * Time: 15:38
 * Created with IntelliJ IDEA.
 */
class Co_occurringTermItemReader implements ItemReader<String> {

    private final AnnotationCoOccurringTermsAggregator aggregator;
    private Iterator<String> termsIt;

    public Co_occurringTermItemReader(AnnotationCoOccurringTermsAggregator annotationCoOccurringTermsAggregator) {
        this.aggregator = annotationCoOccurringTermsAggregator;

    }

    @Override public String read() throws Exception {

        //Delay providing full list until aggregator has fully processed all records.
        if (termsIt == null) {
            termsIt = aggregator.getTermToTermOverlapMatrix().keySet().iterator();
        }

        if (termsIt.hasNext()) {
            return termsIt.next();
        }

        return null;
    }
}

package uk.ac.ebi.quickgo.index.annotation.coterms;

import java.util.Iterator;
import org.springframework.batch.item.ItemReader;

/**
 * Provide a list of all GO Terms for which co-occurrence has been determined ( which is all of them that have been
 * processed, since at worst a GO Term will have a statistic for co-occurring with itself).
 *
 * @author Tony Wardell
 * Date: 07/09/2016
 * Time: 15:38
 * Created with IntelliJ IDEA.
 */
class Co_occurringTermItemReader implements ItemReader<String> {

    private final AnnotationCoOccurringTermsAggregator aggregator;
    private Iterator<String> termsIt;

    public Co_occurringTermItemReader(AnnotationCoOccurringTermsAggregator annotationCoOccurringTermsAggregator) {
        this.aggregator = annotationCoOccurringTermsAggregator;

    }

    @Override public String read() throws Exception {

        //Delay providing full list until aggregator has fully processed all records.
        if (termsIt == null) {
            termsIt = aggregator.getCoTerms().keySet().iterator();
        }

        if (termsIt.hasNext()) {
            return termsIt.next();
        }

        return null;
    }
}

Rename methods and instance variables to make intentions clearer.


/**
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.devtools.cdbg.debuglets.java;

/**
 * Defines the version of the Java Cloud Debugger agent.
 */
public final class GcpDebugletVersion {
  /**
   * Major version of the debugger.

   * All agents of the same major version are compatible with each other. In other words an
   * application can mix different agents with the same major version within the same debuggee.
   */
  public static final int MAJOR_VERSION = 2;

  /**
   * Minor version of the agent.
   */
  public static final int MINOR_VERSION = 13;

  /**
   * Debugger agent version string in the format of MAJOR.MINOR.
   */
  public static final String VERSION = String.format("%d.%d", MAJOR_VERSION, MINOR_VERSION);

  /**
   * Main function to print the version string.
   */
  public static void main(String[] args) {
    System.out.println(VERSION);
  }
}

/**
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.devtools.cdbg.debuglets.java;

/**
 * Defines the version of the Java Cloud Debugger agent.
 */
public final class GcpDebugletVersion {
  /**
   * Major version of the debugger.

   * All agents of the same major version are compatible with each other. In other words an
   * application can mix different agents with the same major version within the same debuggee.
   */
  public static final int MAJOR_VERSION = 2;

  /**
   * Minor version of the agent.
   */
  public static final int MINOR_VERSION = 14;

  /**
   * Debugger agent version string in the format of MAJOR.MINOR.
   */
  public static final String VERSION = String.format("%d.%d", MAJOR_VERSION, MINOR_VERSION);

  /**
   * Main function to print the version string.
   */
  public static void main(String[] args) {
    System.out.println(VERSION);
  }
}

Increment minor version to 2.14 to prepare for a new release.


package io.tracee.backend.jbosslogging;

import io.tracee.MDCLike;
import org.jboss.logging.MDC;

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

final class JbossLoggingMdcLikeAdapter implements MDCLike {

    @Override
    public boolean containsKey(String key) {
        return MDC.get(key) != null;
    }

    @Override
    public void put(String key, String value) {
        MDC.put(key, value);
    }

    @Override
    public String get(String key) {

        return (String) MDC.get(key);
    }

    @Override
    public void remove(String key) {
        MDC.remove(key);
    }

    @Override
    public Map<String, String> getCopyOfContext() {
        final Map<String, Object> map = MDC.getMap();
        final Map<String, String> copy = new HashMap<String, String>(map.size());
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            if (!(entry.getValue() instanceof String)) continue;
            copy.put(entry.getKey(), (String) entry.getValue());
        }
        return copy;
    }
}

package io.tracee.backend.jbosslogging;

import io.tracee.MDCLike;
import org.jboss.logging.MDC;

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

final class JbossLoggingMdcLikeAdapter implements MDCLike {

    @Override
    public boolean containsKey(String key) {
        return MDC.get(key) != null;
    }

    @Override
    public void put(String key, String value) {
        MDC.put(key, value);
    }

    @Override
    public String get(String key) {
        return String.valueOf(MDC.get(key));
    }

    @Override
    public void remove(String key) {
        MDC.remove(key);
    }

    @Override
    public Map<String, String> getCopyOfContext() {
        final Map<String, Object> map = MDC.getMap();
        final Map<String, String> copy = new HashMap<String, String>(map.size());
        for (Map.Entry<String, Object> entry : map.entrySet()) {
			copy.put(entry.getKey(), String.valueOf(entry.getValue()));
        }
        return copy;
    }
}

Use String.valueOf() instead. It's more robust against Object values in the MDC.


/*
 * Copyright 2016-present Facebook, 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.facebook.buck.cxx.toolchain;

import com.facebook.buck.core.toolchain.tool.Tool;
import com.google.common.collect.ImmutableList;
import java.nio.file.Path;

/** Subclass of WindowsCompiler with overrides specific for clang-cl. */
public class ClangClCompiler extends WindowsCompiler {

  public ClangClCompiler(Tool tool) {
    super(tool);
  }

  @Override
  public ImmutableList<String> getFlagsForReproducibleBuild(
      String altCompilationDir, Path currentCellPath) {
    return ImmutableList.of(
        "/Brepro", "-Xclang", "-fdebug-compilation-dir", "-Xclang", altCompilationDir);
  }
}

/*
 * Copyright 2016-present Facebook, 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.facebook.buck.cxx.toolchain;

import com.facebook.buck.core.toolchain.tool.Tool;
import com.facebook.buck.util.ProcessExecutor;
import com.google.common.collect.ImmutableList;
import java.nio.file.Path;
import java.util.Optional;

/** Subclass of WindowsCompiler with overrides specific for clang-cl. */
public class ClangClCompiler extends WindowsCompiler {

  public ClangClCompiler(Tool tool) {
    super(tool);
  }

  @Override
  public ImmutableList<String> getFlagsForReproducibleBuild(
      String altCompilationDir, Path currentCellPath) {
    return ImmutableList.of(
        "/Brepro", "-Xclang", "-fdebug-compilation-dir", "-Xclang", altCompilationDir);
  }

  @Override
  public Optional<String> getStderr(ProcessExecutor.Result result) {
    // clang-cl is sensible
    return result.getStderr();
  }
}

Fix diagnostics output for clang-cl


package net.wizardsoflua.lua.module.print;

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

import net.sandius.rembulan.Table;
import net.sandius.rembulan.lib.BasicLib;
import net.sandius.rembulan.runtime.LuaFunction;

public class PrintRedirector {

  public interface Context {
    public void send(String message);
  }

  public static PrintRedirector installInto(Table env, Context context) {
    return new PrintRedirector(env, context);
  }

  private final Context context;

  public PrintRedirector(Table env, Context context) {
    this.context = context;
    OutputStream out = new ChatOutputStream();
    LuaFunction printFunc = BasicLib.print(out, env);
    env.rawset("print", printFunc);
  }

  private class ChatOutputStream extends org.apache.commons.io.output.ByteArrayOutputStream {
    @Override
    public void flush() throws IOException {
      String message = toString();
      // Remove trailing line-feed.
      if (message.endsWith("\n")) {
        message = message.substring(0, message.length() - 1);
      }
      reset();
      print(message);
    }
  }

  private void print(String message) {
    context.send(TabEncoder.encode(message));
  }
}

package net.wizardsoflua.lua.module.print;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import net.sandius.rembulan.Table;
import net.sandius.rembulan.lib.BasicLib;
import net.sandius.rembulan.runtime.LuaFunction;

public class PrintRedirector {

  public interface Context {
    public void send(String message);
  }

  public static PrintRedirector installInto(Table env, Context context) {
    return new PrintRedirector(env, context);
  }

  private final Context context;

  public PrintRedirector(Table env, Context context) {
    this.context = context;
    OutputStream out = new ChatOutputStream();
    LuaFunction printFunc = BasicLib.print(out, env);
    env.rawset("print", printFunc);
  }

  private class ChatOutputStream extends org.apache.commons.io.output.ByteArrayOutputStream {
    @Override
    public void flush() throws IOException {
      String message = toString(Charset.defaultCharset());
      // Remove trailing line-feed.
      if (message.endsWith("\n")) {
        message = message.substring(0, message.length() - 1);
      }
      reset();
      print(message);
    }
  }

  private void print(String message) {
    context.send(TabEncoder.encode(message));
  }
}

Remove use of the deprecated method ByteArrayOutputStream.toString()


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

import android.text.TextUtils;
import android.widget.EditText;

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

/**
 * Created by bloder on 31/07/16.
 */
public class Number extends Validation {

  EditText editText;

  @Override
  public Validate validate() {
    return new Validate() {
      @Override
      public boolean validate() {
        editText = (EditText) field;
        if (editText.getText().toString().isEmpty()) return false;
        return TextUtils.isDigitsOnly(editText.getText().toString());
      }

      @Override
      public void onError() {
        editText.setError("This field only accept numbers!");
      }

      @Override
      public void onSuccess() {

      }
    };
  }
}

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

import android.text.TextUtils;
import android.widget.EditText;

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

/**
 * Created by bloder on 31/07/16.
 */
public class Number extends Validation {

  EditText editText;

  @Override
  public Validate validate() {
    return new Validate() {
      @Override
      public boolean validate() {
        editText = (EditText) field;
        if (editText.getText().toString().isEmpty()) return false;
        return TextUtils.isDigitsOnly(editText.getText().toString());
      }

      @Override
      public void onError() {
        editText.setError(errorMessage != null || !errorMessage.isEmpty() ? errorMessage : "This field only accept numbers!");
      }

      @Override
      public void onSuccess() {

      }
    };
  }
}

Add custom error message to number validation


package com.ezardlabs.dethsquare.multiplayer;

import com.ezardlabs.dethsquare.Component;

import java.nio.ByteBuffer;

public abstract class NetworkBehaviour extends Component {
	private static int networkIdCounter = 0;
	int networkId;
	protected int playerId;
	protected final ByteBuffer data = ByteBuffer.allocate(getSize());

	public NetworkBehaviour() {
		this(networkIdCounter++, Network.getPlayerID());
	}

	NetworkBehaviour(int networkId, int playerId) {
		this.networkId = networkId;
		this.playerId = playerId;
	}

	protected abstract ByteBuffer onSend();

	protected abstract void onReceive(ByteBuffer data, int index);

	public abstract int getSize();
}

package com.ezardlabs.dethsquare.multiplayer;

import com.ezardlabs.dethsquare.Component;

import java.nio.ByteBuffer;
import java.util.Random;

public abstract class NetworkBehaviour extends Component {
	String networkId;
	protected int playerId;
	protected final ByteBuffer data = ByteBuffer.allocate(getSize());

	public NetworkBehaviour() {
		networkId = generateRandomId();
		playerId = Network.getPlayerID();
	}

	private String generateRandomId() {
		char[] chars = {'0',
				'1',
				'2',
				'3',
				'4',
				'5',
				'6',
				'7',
				'8',
				'9',
				'a',
				'b',
				'c',
				'd',
				'e',
				'f',
				'g',
				'h',
				'i',
				'j',
				'k',
				'l',
				'm',
				'n',
				'o',
				'p',
				'q',
				'r',
				's',
				't',
				'u',
				'v',
				'w',
				'x',
				'y',
				'z',
				'A',
				'B',
				'C',
				'D',
				'E',
				'F',
				'G',
				'H',
				'I',
				'J',
				'K',
				'L',
				'M',
				'N',
				'O',
				'P',
				'Q',
				'R',
				'S',
				'T',
				'U',
				'V',
				'W',
				'X',
				'Y',
				'Z'};
		Random r = new Random();
		StringBuilder sb = new StringBuilder(10);
		for (int i = 0; i < sb.capacity(); i++) {
			sb.append(chars[r.nextInt(chars.length)]);
		}
		return sb.toString();
	}

	protected abstract ByteBuffer onSend();

	protected abstract void onReceive(ByteBuffer data, int index);

	public abstract int getSize();
}

Change from integer network IDs to random strings


package de.gurkenlabs.litiengine;

public class GameTime {
  private final IGameLoop gameLoop;

  public GameTime(final IGameLoop loop) {
    this.gameLoop = loop;
  }

  public long getDays() {
    return this.getMilliseconds() / 1000 / 60 / 60 / 24 % 365;
  }

  public long getHours() {
    return this.getMilliseconds() / 1000 / 60 / 60 % 24;
  }

  public long getMilliseconds() {
    return this.gameLoop.convertToMs(this.gameLoop.getTicks());
  }

  public long getMinutes() {
    return this.getMilliseconds() / 1000 / 60 % 60;
  }

  public long getSeconds() {
    return this.getMilliseconds() / 1000 % 60;
  }

  public long getYears() {
    return this.getMilliseconds() / 1000 / 60 / 60 / 24 / 365;
  }
}

package de.gurkenlabs.litiengine;

public class GameTime {
  private final IGameLoop gameLoop;

  public GameTime(final IGameLoop loop) {
    this.gameLoop = loop;
  }

  public long getDays() {
    return getDays(this.getMilliseconds());
  }

  public long getHours() {
    return getHours(this.getMilliseconds());
  }

  public long getMilliseconds() {
    return this.gameLoop.convertToMs(this.gameLoop.getTicks());
  }

  public long getMinutes() {
    return getMinutes(this.getMilliseconds());
  }

  public long getSeconds() {
    return getSeconds(this.getMilliseconds());
  }

  public long getYears() {
    return getYears(this.getMilliseconds());
  }

  public static long getDays(long ms) {
    return ms / 1000 / 60 / 60 / 24 % 365;
  }

  public static long getHours(long ms) {
    return ms / 1000 / 60 / 60 % 24;
  }

  public static long getMinutes(long ms) {
    return ms / 1000 / 60 % 60;
  }

  public static long getSeconds(long ms) {
    return ms / 1000 % 60;
  }

  public static long getMilliSeconds(long ms) {
    return ms % 1000;
  }

  public static long getYears(long ms) {
    return ms / 1000 / 60 / 60 / 24 / 365;
  }
}

Extend game time by static methods to get parts of a time format