/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2011 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */
package org.geomajas.configuration.client;

import java.io.Serializable;

/**
 * Enumeration class for the available options to limit (e.g. the mapview's) bounds when applying
 * 		the maxBounds limitation.
 *
 * @author An Buyle
 *
 * @since 1.10.0
 */
public enum BoundsLimitOption implements Serializable {

	/**
	 *  View center must be within maxBounds.
	 */
	CENTER_WITHIN_MAX_BOUNDS,
	/**
	 * The whole map view must lay completely within the maximum allowed bounds (maxBounds).
	 */
	COMPLETELY_WITHIN_MAX_BOUNDS;

	private static final long serialVersionUID = 1100L;

}

/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2011 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */
package org.geomajas.configuration.client;

import java.io.Serializable;
import org.geomajas.annotation.Api;

/**
 * Enumeration class for the available options to limit (e.g. the mapview's) bounds when applying
 * 		the maxBounds limitation.
 *
 * @author An Buyle
 *
 * @since 1.10.0
 */
@Api
public enum BoundsLimitOption implements Serializable {

	/**
	 *  View center must be within maxBounds.
	 */
	CENTER_WITHIN_MAX_BOUNDS,
	/**
	 * The whole map view must lay completely within the maximum allowed bounds (maxBounds).
	 */
	COMPLETELY_WITHIN_MAX_BOUNDS;

	private static final long serialVersionUID = 1100L;

}

Fix missing @api (see comment of Joachim Van der Auwera on GBE-247)


package org.testcontainers.junit.jupiter.inheritance;

import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Container;

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

class InheritedTests extends AbstractTestBase {

    @Container
    private RedisContainer myRedis = new RedisContainer();

    @Test
    void step1() {
        assertEquals(1, redisPerClass.getJedis().incr("key").longValue());
        assertEquals(1, redisPerTest.getJedis().incr("key").longValue());
        assertEquals(1, myRedis.getJedis().incr("key").longValue());
    }

    @Test
    void step2() {
        assertEquals(2, redisPerClass.getJedis().incr("key").longValue());
        assertEquals(1, redisPerTest.getJedis().incr("key").longValue());
        assertEquals(1, myRedis.getJedis().incr("key").longValue());
    }
}

package org.testcontainers.junit.jupiter.inheritance;

import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Container;

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

class InheritedTests extends AbstractTestBase {

    @Container
    private RedisContainer myRedis = new RedisContainer();

    @Test
    void step1() {
        assertEquals(1, redisPerClass.getJedis().incr("key"));
        assertEquals(1, redisPerTest.getJedis().incr("key"));
        assertEquals(1, myRedis.getJedis().incr("key"));
    }

    @Test
    void step2() {
        assertEquals(2, redisPerClass.getJedis().incr("key"));
        assertEquals(1, redisPerTest.getJedis().incr("key"));
        assertEquals(1, myRedis.getJedis().incr("key"));
    }
}

Fix for API changes in Jedis


/*
 * Copyright (c) 2022, Inversoft 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 org.primeframework.mvc.netty;

/**
 * @author Daniel DeGroff
 */
public class PrimeHTTPServerConfiguration {
  /**
   * The port to bind to the HTTP server.
   */
  public final int port;

  /**
   * HTTP connection read timeout in seconds.
   */
  public final int readTimeout;

  /**
   * The scheme used by the channel handler.
   */
  public final String scheme;

  public PrimeHTTPServerConfiguration(int port, int readTimeout, String scheme) {
    this.port = port;
    this.readTimeout = readTimeout;
    this.scheme = scheme;
  }
}

/*
 * Copyright (c) 2022, Inversoft 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 org.primeframework.mvc.netty;

/**
 * @author Daniel DeGroff
 */
public class PrimeHTTPServerConfiguration {
  /**
   * The port to bind to the HTTP server.
   */
  public final int port;

  /**
   * HTTP connection read timeout in seconds.
   */
  public final long readTimeout;

  /**
   * The scheme used by the channel handler.
   */
  public final String scheme;

  public PrimeHTTPServerConfiguration(int port, int readTimeout, String scheme) {
    this.port = port;
    this.readTimeout = readTimeout;
    this.scheme = scheme;
  }
}

Use long instead of int


// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)

package org.xbill.DNS;

import java.io.*;

/**
 * An exception thrown when a DNS message is invalid.
 *
 * @author Brian Wellington
 */

public class WireParseException extends IOException {

public
WireParseException() {
	super();
}

public
WireParseException(String s) {
	super(s);
}

}

// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)

package org.xbill.DNS;

import java.io.*;

/**
 * An exception thrown when a DNS message is invalid.
 *
 * @author Brian Wellington
 */

public class WireParseException extends IOException {

public
WireParseException() {
	super();
}

public
WireParseException(String s) {
	super(s);
}

public
WireParseException(String s, Throwable cause) {
	super(s, cause);
}

}

Add a constructor that takes a cause Exception.


package com.hwangjr.rxbus;

/**
 * Instance of {@link Bus}.
 * Simply use {@link #get()} to get the instance of {@link Bus}
 */
public class RxBus {

    /**
     * Instance of {@link Bus}
     */
    private static Bus sBus;

    /**
     * Get the instance of {@link Bus}
     *
     * @return
     */
    public static synchronized Bus get() {
        if (sBus == null) {
            sBus = new Bus();
        }
        return sBus;
    }
}

package com.hwangjr.rxbus;

import com.hwangjr.rxbus.thread.ThreadEnforcer;

/**
 * Instance of {@link Bus}.
 * Simply use {@link #get()} to get the instance of {@link Bus}
 */
public class RxBus {

    /**
     * Instance of {@link Bus}
     */
    private static Bus sBus;

    /**
     * Get the instance of {@link Bus}
     *
     * @return
     */
    public static synchronized Bus get() {
        if (sBus == null) {
            sBus = new Bus(ThreadEnforcer.ANY);
        }
        return sBus;
    }
}

Modify default rxbus from MainThreadEnforce to AnyThreadEnforce


package com.youcruit.billogram.objects.response.billogram;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.youcruit.billogram.objects.response.event.CallbackEvent;

public class Callback {
    @Expose
    CallbackBillogram billogram;
    @Expose
    CallbackEvent event;
    @Expose
    private String url;
    @SerializedName("sign_key")
    @Expose
    private String signKey;
    @Expose
    private String custom;

    public String getUrl() {
	return url;
    }

    public void setUrl(String url) {
	this.url = url;
    }

    public String getSignKey() {
	return signKey;
    }

    public void setSignKey(String signKey) {
	this.signKey = signKey;
    }

    public String getCustom() {
	return custom;
    }

    public void setCustom(String custom) {
	this.custom = custom;
    }
}

package com.youcruit.billogram.objects.response.billogram;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.youcruit.billogram.objects.response.event.CallbackEvent;

public class Callback {
    @Expose
    private CallbackBillogram billogram;
    @Expose
    private CallbackEvent event;
    @Expose
    private String url;
    @SerializedName("sign_key")
    @Expose
    private String signKey;
    @Expose
    private String custom;
    @Expose
    @SerializedName("callback_id")
    private String callbackId;

    public String getUrl() {
	return url;

    }
    public void setUrl(String url) {
	this.url = url;
    }

    public String getSignKey() {
	return signKey;
    }

    public void setSignKey(String signKey) {
	this.signKey = signKey;
    }

    public String getCustom() {
	return custom;
    }

    public void setCustom(String custom) {
	this.custom = custom;
    }

    public void verifySignature(String key) {

    }

    public CallbackBillogram getBillogram() {
        return billogram;
    }

    public void setBillogram(CallbackBillogram billogram) {
        this.billogram = billogram;
    }

    public CallbackEvent getEvent() {
        return event;
    }

    public void setEvent(CallbackEvent event) {
        this.event = event;
    }

    public String getCallbackId() {
        return callbackId;
    }

    public void setCallbackId(String callbackId) {
        this.callbackId = callbackId;
    }

}

Add event & billogram to callback WITH getters


/**
 * @file FileName.java
 * @author samov004
 * @version 1.0.0
 * @date 9/9/15
 */

package com.samovich.basics.concepts.objects.treehouse;

public class PezDispenser {

    private String characterName;

    // Constructor
    public PezDispenser(String characterName){
        this.characterName = characterName;
    }

    // Getter
    public String getCharacterName() {
        return characterName;
    }

}

/**
 * @file FileName.java
 * @author samov004
 * @version 1.0.0
 * @date 9/9/15
 */

package com.samovich.basics.concepts.objects.treehouse;

public class PezDispenser {

    public static final int MAX_PEZ = 12;
    private String characterName;
    private int pezCount;

    // Constructor
    public PezDispenser(String characterName){
        this.characterName = characterName;
        this.pezCount = 0;
    }

    // Getter
    public String getCharacterName() {
        return characterName;
    }

    public void load(){
        this.pezCount = MAX_PEZ;
    }
}

Add constant to the class


package com.allthatseries.RNAudioPlayer;

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

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;

public class RNAudioPlayerPackage implements ReactPackage {

  @Override
  public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new RNAudioPlayerModule(reactContext));

    return modules;
  }

  @Override
  public List<Class<? extends JavaScriptModule>> createJSModules() {
  	return Collections.emptyList();
  }

  @Override
  public List<ViewManager> createViewManagers(
                            ReactApplicationContext reactContext) {
  	return Collections.emptyList();
  }
}

package com.allthatseries.RNAudioPlayer;

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

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;

public class RNAudioPlayerPackage implements ReactPackage {

  @Override
  public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new RNAudioPlayerModule(reactContext));

    return modules;
  }

  // @Override
  public List<Class<? extends JavaScriptModule>> createJSModules() {
  	return Collections.emptyList();
  }

  @Override
  public List<ViewManager> createViewManagers(
                            ReactApplicationContext reactContext) {
  	return Collections.emptyList();
  }
}

Comment out @override in createJSModules


package cloudSimulator.dto;

import org.springframework.data.annotation.Id;

public class RequestDetails {

    @Id
    private String id;

    private long requestId;
    private double responseTime;

    public RequestDetails() {
    }

    public RequestDetails(long requestId, double responseTime) {
        this.requestId = requestId;
        this.responseTime = responseTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public long getRequestId() {
        return requestId;
    }

    public void setRequestId(long requestId) {
        this.requestId = requestId;
    }

    public double getResponseTime() {
        return responseTime;
    }

    public void setResponseTime(double responseTime) {
        this.responseTime = responseTime;
    }

}

package cloudSimulator.dto;

import org.springframework.data.annotation.Id;

public class RequestDetails {

    @Id
    private String id;

    private long requestId;
    private double requestArrivalTime;
    private double responseTime;

    public RequestDetails() {
    }

    public RequestDetails(long requestId, double requestArrivalTime) {
        this.requestId = requestId;
        this.requestArrivalTime = requestArrivalTime;
    }

    public RequestDetails(long requestId, double requestArrivalTime, double responseTime) {
        this.requestId = requestId;
        this.requestArrivalTime = requestArrivalTime;
        this.responseTime = responseTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public long getRequestId() {
        return requestId;
    }

    public void setRequestId(long requestId) {
        this.requestId = requestId;
    }

    public double getRequestArrivalTime() {
        return requestArrivalTime;
    }

    public void setRequestArrivalTime(double requestArrivalTime) {
        this.requestArrivalTime = requestArrivalTime;
    }

    public double getResponseTime() {
        return responseTime;
    }

    public void setResponseTime(double responseTime) {
        this.responseTime = responseTime;
    }

}

Add arrival time and update constructor.


package com.reactnativenavigation.bridge;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.reactnativenavigation.views.managers.SharedElementTransitionManager;

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

public class NavigationReactPackage implements ReactPackage {

    @Override
    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
        return Arrays.<NativeModule>asList(
                new NavigationReactModule(reactContext)
        );
    }

    @Override
    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
        return Arrays.<ViewManager>asList(
                new SharedElementTransitionManager()
        );
    }
}

package com.reactnativenavigation.bridge;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.reactnativenavigation.views.managers.SharedElementTransitionManager;

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

public class NavigationReactPackage implements ReactPackage {

    @Override
    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
        return Arrays.<NativeModule>asList(
                new NavigationReactModule(reactContext)
        );
    }

    public List<Class<? extends JavaScriptModule>> createJSModules() {
        return Collections.emptyList();
    }

    @Override
    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
        return Arrays.<ViewManager>asList(
                new SharedElementTransitionManager()
        );
    }
}

Add backwards compatibility to Android lib


public class Increment
{
	public static void main(String[] args)
	{
		// Starting at zero because floats are small
		// Explicit cast required to because 0.0 is parsed as a double
		float incrementee = (float)0.0;

		// Stop counting when we lose resolution of 1.0
		while((incrementee + (float)1.0) - incrementee > 0.999999999) {
			incrementee += 1.0;
		}

		System.out.printf("%f\n", incrementee);
	}
}

public class Increment
{
	public static void main(String[] args)
	{
		// Starting at zero because floats are small
		// Explicitly create as a float rather than double
		float incrementee = 0.0f;

		// Stop counting when we lose resolution of 1.0
		while((incrementee + 1.0f) - incrementee > 0.999999999) {
			incrementee += 1.0f;
		}

		System.out.printf("%f\n", incrementee);
	}
}

Change numeric float constants to use the `f` suffix in Java


package com.ogsdroid;

import android.app.Application;
import android.content.Context;

import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;

@ReportsCrashes(
        mailTo = "nathanj439@gmail.com",
        mode = ReportingInteractionMode.TOAST,
        resToastText = R.string.crash_toast_text
)

public class MyApplication extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);

        // The following line triggers the initialization of ACRA
        ACRA.init(this);
    }

}

package com.ogsdroid;

import android.app.Application;
import android.content.Context;

import org.acra.ACRA;
import org.acra.ReportField;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;

@ReportsCrashes(
        mailTo = "nathanj439@gmail.com",
        mode = ReportingInteractionMode.TOAST,
        customReportContent = {ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.STACK_TRACE, ReportField.LOGCAT },
        resToastText = R.string.crash_toast_text
)

public class MyApplication extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);

        // The following line triggers the initialization of ACRA
        ACRA.init(this);
    }

}

Include logcat in crash reports


package org.realityforge.replicant.server.transport;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import org.realityforge.replicant.server.EntityMessage;

/**
 * A simple class that collects EntityMessage instances and then
 * on "completion" passes the messages to a client.
 */
public final class EntityMessageAccumulator
{
  private final Map<PacketQueue, LinkedList<EntityMessage>> _changeSets = new HashMap<>();

  /**
   * Add a message to a client.
   *
   * @param client the client/
   * @param message the message.
   */
  public void addEntityMessage( final PacketQueue client, final EntityMessage message )
  {
    getChangeSet( client ).add( message );
  }

  /**
   * Complete the collection of messages and forward them to the client.
   */
  public void complete()
  {
    for ( final Entry<PacketQueue, LinkedList<EntityMessage>> entry : _changeSets.entrySet() )
    {
      entry.getKey().addPacket( entry.getValue() );
    }
    _changeSets.clear();
  }

  private LinkedList<EntityMessage> getChangeSet( final PacketQueue info )
  {
    LinkedList<EntityMessage> clientChangeSet = _changeSets.get( info );
    if ( null == clientChangeSet )
    {
      clientChangeSet = new LinkedList<>();
      _changeSets.put( info, clientChangeSet );
    }
    return clientChangeSet;
  }
}

package org.realityforge.replicant.server.transport;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import org.realityforge.replicant.server.EntityMessage;

/**
 * A simple class that collects EntityMessage instances and then
 * on "completion" passes the messages to a client.
 */
public final class EntityMessageAccumulator
{
  private final Map<PacketQueue, LinkedList<EntityMessage>> _changeSets = new HashMap<>();

  /**
   * Add a message destined for a particular packet queue.
   *
   * @param queue the queue.
   * @param message the message.
   */
  public void addEntityMessage( final PacketQueue queue, final EntityMessage message )
  {
    getChangeSet( queue ).add( message );
  }

  /**
   * Complete the collection of messages and forward them to the client.
   */
  public void complete()
  {
    for ( final Entry<PacketQueue, LinkedList<EntityMessage>> entry : _changeSets.entrySet() )
    {
      entry.getKey().addPacket( entry.getValue() );
    }
    _changeSets.clear();
  }

  private LinkedList<EntityMessage> getChangeSet( final PacketQueue queue )
  {
    LinkedList<EntityMessage> clientChangeSet = _changeSets.get( queue );
    if ( null == clientChangeSet )
    {
      clientChangeSet = new LinkedList<>();
      _changeSets.put( queue, clientChangeSet );
    }
    return clientChangeSet;
  }
}

Improve the naming of the variables


package de.gurkenlabs.litiengine.environment.tilemap.xml;

import java.util.ArrayList;

import org.junit.Test;

import junit.framework.Assert;

public class CustomPropertyProviderTests {

  @Test
  public void testSetCustomProperty() {
    CustomPropertyProvider propProvider = new CustomPropertyProvider();
    propProvider.setCustomProperty("test", "testvalue");

    Assert.assertEquals("testvalue", propProvider.getCustomProperty("test"));
    Assert.assertNull(propProvider.getCustomProperty("test2"));
    Assert.assertEquals(1, propProvider.getAllCustomProperties().size());

    propProvider.setCustomProperty("test", "testvalue2");

    Assert.assertEquals("testvalue2", propProvider.getCustomProperty("test"));

    ArrayList<Property> props = new ArrayList<>();
    props.add(new Property("test2", "testvalue3"));
    props.add(new Property("test3", "testvalue4"));

    propProvider.setCustomProperties(props);

    Assert.assertEquals(2, propProvider.getAllCustomProperties().size());
    Assert.assertEquals("testvalue3", propProvider.getCustomProperty("test2"));
    Assert.assertEquals("testvalue4", propProvider.getCustomProperty("test3"));
  }
}

package de.gurkenlabs.litiengine.environment.tilemap.xml;

import java.util.ArrayList;

import org.junit.Test;

import junit.framework.Assert;

public class CustomPropertyProviderTests {

  @Test
  public void testSetCustomProperty() {
    CustomPropertyProvider propProvider = new CustomPropertyProvider();
    propProvider.setCustomProperty("test", "testvalue");

    Assert.assertEquals("testvalue", propProvider.getCustomProperty("test"));
    Assert.assertNull(propProvider.getCustomProperty("test2"));
    Assert.assertEquals(1, propProvider.getAllCustomProperties().size());

    propProvider.setCustomProperty("test", "testvalue2");

    Assert.assertEquals("testvalue2", propProvider.getCustomProperty("test"));

    ArrayList<Property> props = new ArrayList<>();
    props.add(new Property("test2", "testvalue3"));
    props.add(new Property("test3", "testvalue4"));

    propProvider.setCustomProperties(props);

    Assert.assertEquals(2, propProvider.getAllCustomProperties().size());
    Assert.assertEquals("testvalue3", propProvider.getCustomProperty("test2"));
    Assert.assertEquals("testvalue4", propProvider.getCustomProperty("test3"));

    propProvider.setCustomProperties(null);
    Assert.assertNull(propProvider.getAllCustomProperties());
  }
}

Add another test case for the CustomPropertyProvider.


package org.motechproject.tama.api.model;

/**
 * Created by IntelliJ IDEA.
 * User: rob
 * Date: 4/25/11
 * Time: 8:48 PM
 * To change this template use File | Settings | File Templates.
 */
public class AppointmentSchedule
{
	public static enum Followup {
		REGISTERED("Registered",7),
		WEEK4("4 week follow-up",4*7),
		WEEK12("12 week follow-up",4*12),
		WEEK24("24 week follow-up",4*24),
		WEEK36("36 week follow-up",4*36),
		WEEK48("48 week follow-up",4*48);

		final String value;
		final int days;

		Followup(String value, int days) {
			this.value=value;
			this.days=days;
		}

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

		public String getKey(){
			return name();
		}

		public int getDays() {
			return this.days;
		}
	}
}

package org.motechproject.tama.api.model;

/**
 * Created by IntelliJ IDEA.
 * User: rob
 * Date: 4/25/11
 * Time: 8:48 PM
 * To change this template use File | Settings | File Templates.
 */
public class AppointmentSchedule
{
	public static enum Followup {
		REGISTERED("Registered",7),
		WEEK4("4 week follow-up",7*4),
		WEEK12("12 week follow-up",7*12),
		WEEK24("24 week follow-up",7*24),
		WEEK36("36 week follow-up",7*36),
		WEEK48("48 week follow-up",7*48);

		final String value;
		final int days;

		Followup(String value, int days) {
			this.value=value;
			this.days=days;
		}

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

		public String getKey(){
			return name();
		}

		public int getDays() {
			return this.days;
		}
	}
}

Fix 4->7 days week in the Care Schedule


package hello;

import java.util.Arrays;

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

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        ApplicationContext ctx = SpringApplication.run(Application.class, args);

        System.out.println("Let's inspect the beans provided by Spring Boot:");

        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
        for (String beanName : beanNames) {
            System.out.println(beanName);
        }
    }

}

package hello;

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

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        ApplicationContext ctx = SpringApplication.run(Application.class, args);
    }

}

Remove unnecesary system.out.printlns from the starting code


package protocolsupport.protocol.packet.middleimpl.clientbound.play.v_4_5_6_7;

import protocolsupport.protocol.packet.ClientBoundPacket;
import protocolsupport.protocol.packet.middle.clientbound.play.MiddleKeepAlive;
import protocolsupport.protocol.packet.middleimpl.ClientBoundPacketData;
import protocolsupport.utils.recyclable.RecyclableCollection;
import protocolsupport.utils.recyclable.RecyclableSingletonList;

public class KeepAlive extends MiddleKeepAlive {

	@Override
	public RecyclableCollection<ClientBoundPacketData> toData() {
		ClientBoundPacketData serializer = ClientBoundPacketData.create(ClientBoundPacket.PLAY_KEEP_ALIVE_ID, connection.getVersion());
		serializer.writeInt(1);
		return RecyclableSingletonList.create(serializer);
	}

}

package protocolsupport.protocol.packet.middleimpl.clientbound.play.v_4_5_6_7;

import protocolsupport.protocol.packet.ClientBoundPacket;
import protocolsupport.protocol.packet.middle.clientbound.play.MiddleKeepAlive;
import protocolsupport.protocol.packet.middleimpl.ClientBoundPacketData;
import protocolsupport.utils.recyclable.RecyclableCollection;
import protocolsupport.utils.recyclable.RecyclableSingletonList;

public class KeepAlive extends MiddleKeepAlive {

	@Override
	public RecyclableCollection<ClientBoundPacketData> toData() {
		ClientBoundPacketData serializer = ClientBoundPacketData.create(ClientBoundPacket.PLAY_KEEP_ALIVE_ID, connection.getVersion());
		serializer.writeInt(keepAliveId);
		return RecyclableSingletonList.create(serializer);
	}

}

Fix wrong keep alive ids being sent for <= 1.7


package org.iotbricks.core.amqp.transport.utils;

import static java.util.Optional.empty;
import static java.util.Optional.of;

import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
import org.apache.qpid.proton.message.Message;

public final class Properties {
    private Properties() {
    }

    /**
     * Extract the {@code status} value as Integer from the message
     *
     * @param message
     *            the message to extract the value from
     * @return the status value, never {@code null}, but may be
     *         {@link Optional#empty()}
     */
    public static Optional<Integer> status(final Message message) {
        Objects.requireNonNull(message);

        // get application properties

        final ApplicationProperties properties = message.getApplicationProperties();
        if (properties == null) {
            return empty();
        }

        // get value map

        final Map<?, ?> value = properties.getValue();
        if (value == null) {
            return empty();
        }

        // get status value

        final Object status = value.get("status");
        if (status instanceof Number) {
            // return value as int
            return of(((Number) status).intValue());
        }

        // return nothing

        return empty();
    }
}

package org.iotbricks.core.amqp.transport.utils;

import static java.util.Optional.empty;
import static java.util.Optional.of;

import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
import org.apache.qpid.proton.message.Message;

public final class Properties {
    private Properties() {
    }

    /**
     * Extract the {@code status} value as Integer from the message
     *
     * @param message
     *            the message to extract the value from
     * @return the status value, never {@code null}, but may be
     *         {@link Optional#empty()}
     */
    public static Optional<Integer> status(final Message message) {
        Objects.requireNonNull(message);

        // get application properties

        final ApplicationProperties properties = message.getApplicationProperties();
        if (properties == null) {
            return empty();
        }

        // get value map

        final Map<?, ?> value = properties.getValue();
        if (value == null) {
            return empty();
        }

        // get status value

        final Object status = value.get("status");

        if (status == null) {
            return empty();
        }

        if (status instanceof Number) {
            // return value as int
            return of(((Number) status).intValue());
        }

        try {
            return of(Integer.parseInt(status.toString()));
        } catch (final NumberFormatException e) {
        }

        // return nothing

        return empty();
    }
}

Allow decoding the status as string value


package com.infinityraider.agricraft.renderers.particles;

//heavily inspired by the OpenBlocks sprinkler
import com.infinityraider.agricraft.utility.BaseIcons;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class LiquidSprayFX extends AgriCraftFX {

    public LiquidSprayFX(World world, double x, double y, double z, float scale, float gravity, Vec3d vector) {
        super(world, x, y, z, scale, gravity, vector, new ResourceLocation("minecraft:textures/blocks/water_still.png"));
        this.particleMaxAge = 15;
        this.setSize(0.2f, 0.2f);
    }
}

package com.infinityraider.agricraft.renderers.particles;

//heavily inspired by the OpenBlocks sprinkler
import com.infinityraider.agricraft.utility.BaseIcons;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class LiquidSprayFX extends AgriCraftFX {

    public LiquidSprayFX(World world, double x, double y, double z, float scale, float gravity, Vec3d vector) {
        super(world, x, y, z, scale, gravity, vector, new ResourceLocation("minecraft:textures/blocks/water_still.png"));
        this.particleMaxAge = 15;
        this.setSize(0.2f, 0.2f);
    }

    @Override
    public void renderParticle(VertexBuffer worldRenderer, Entity entity, float partialTicks, float f0, float f1, float f2, float f3, float f4) {
        Minecraft.getMinecraft().renderEngine.bindTexture(this.texture);
        super.renderParticle(worldRenderer, entity, partialTicks, f0, f1, f2, f3, f4);
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    }
}

Replace texture after rendering sprinkler particle


package org.junit5.poc;

import java.util.HashMap;

import org.junit.lambda.launch.JUnitLauncher;
import org.junit.lambda.launch.TestRun;

/**
 * @author Sam Brannen
 * @since 5.0
 */
public class JUnit5Demo {

	@SuppressWarnings("serial")
	public static void main(String... args) {

		TestRun testRun = new JUnitLauncher()
				.parameters(new HashMap<String, String>(){{
					put("category", "smoke");
				}})
				.packageNames("org.junit5.poc")
				.include("*Tests")
				.build();

		testRun.start();

		testRun.stop();
	}

}

package org.junit5.poc;

import java.util.HashMap;

import org.junit.lambda.launch.JUnitLauncher;
import org.junit.lambda.launch.TestRun;

/**
 * @author Sam Brannen
 * @since 5.0
 */
public class JUnit5Demo {

	@SuppressWarnings("serial")
	public static void main(String... args) {

		TestRun testRun = new JUnitLauncher()
				.parameters(new HashMap<String, String>(){{
					put("category", "smoke");
				}})
				.packageNames("org.junit5.poc")
				.include("*Tests")
				// TODO from TestDescriptor ID
				.build();

		testRun.start();

		testRun.stop();
	}

}

Add TODO for "from descriptor ID"


package data;

import static org.junit.Assert.assertSame;

import java.util.Arrays;
import java.util.List;

import javax.persistence.metamodel.SingularAttribute;

import org.junit.Test;

import com.darwinsys.todo.model.Priority;
import com.darwinsys.todo.model.Task;

/**
 * ATM this tests ONLY the default method in the List interface;
 * need to move to Arquillian to test the actual list methods.
 */
public class TodoListTest {

	@Test
	public void testOrderByPrio() {
		Task t0 = new Task();
		t0.setName("t0");
		t0.setPriority(Priority.Low);

		Task t1 = new Task();
		t1.setName("t1");
		t1.setPriority(Priority.Top);

		List<Task> l = Arrays.asList(new Task[] { t0, t1 });

		List<Task> sorted = TodoList.orderByPriority(l);

		assertSame(t0, sorted.get(1));
		assertSame(t1, sorted.get(0));
	}
}

package data;

import static org.junit.Assert.assertSame;

import java.util.Arrays;
import java.util.List;

import javax.persistence.metamodel.SingularAttribute;

import org.junit.Test;

import com.darwinsys.todo.model.Priority;
import com.darwinsys.todo.model.Task;

/**
 * Empty ATM.  Need to move to Arquillian to test the actual list methods.
 */
public class TodoListTest {
	// empty
}

Remove test that has been obviated by progress


package uk.ac.ebi.atlas.search.analyticsindex;

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.springframework.context.annotation.Scope;
import uk.ac.ebi.atlas.search.analyticsindex.solr.AnalyticsClient;
import uk.ac.ebi.atlas.search.analyticsindex.solr.AnalyticsQueryBuilder;
import uk.ac.ebi.atlas.solr.SolrUtil;
import uk.ac.ebi.atlas.web.GeneQuery;

import javax.inject.Inject;
import javax.inject.Named;

@Named
@Scope("singleton")
public class AnalyticsSearchService {

    private AnalyticsClient analyticsClient;

    @Inject
    public AnalyticsSearchService(AnalyticsClient analyticsClient) {
        this.analyticsClient = analyticsClient;
    }

    public Optional<ImmutableSet<String>> searchBioentityIdentifiers(GeneQuery geneQuery, String species) {
        QueryResponse queryResponse = analyticsClient.query(new AnalyticsQueryBuilder().queryIdentifierSearch(geneQuery).ofSpecies(species).setRows(0).facetByBioentityIdentifier().build());
        return Optional.of(SolrUtil.extractFirstFacetValues(queryResponse));
    }
}

package uk.ac.ebi.atlas.search.analyticsindex;

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.springframework.context.annotation.Scope;
import uk.ac.ebi.atlas.search.analyticsindex.solr.AnalyticsClient;
import uk.ac.ebi.atlas.search.analyticsindex.solr.AnalyticsQueryBuilder;
import uk.ac.ebi.atlas.solr.SolrUtil;
import uk.ac.ebi.atlas.web.GeneQuery;

import javax.inject.Inject;
import javax.inject.Named;

@Named
@Scope("singleton")
public class AnalyticsSearchService {

    private AnalyticsClient analyticsClient;

    @Inject
    public AnalyticsSearchService(AnalyticsClient analyticsClient) {
        this.analyticsClient = analyticsClient;
    }

    public ImmutableSet<String> searchBioentityIdentifiers(GeneQuery geneQuery, String species) {
        QueryResponse queryResponse = analyticsClient.query(new AnalyticsQueryBuilder().queryIdentifierSearch(geneQuery).ofSpecies(species).setRows(0).facetByBioentityIdentifier().build());
        return SolrUtil.extractFirstFacetValues(queryResponse);
    }
}

Remove Optional (Optional of a Set, when the Set can be empty seems overengineering things)


package dk.cmol.arduinorgb_controller;

import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

public class SliderFragment extends Fragment {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_slider,
				container, false);

		return rootView;
	}

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

		boolean[] lamps = ((ArduinoRGBActivity) getActivity()).lamp_toggle;

		Button btns[] = { (Button) getActivity().findViewById(R.id.lamp1),
				(Button) getActivity().findViewById(R.id.lamp2),
				(Button) getActivity().findViewById(R.id.lamp3),
				(Button) getActivity().findViewById(R.id.lamp4) };

		for (int i = 0; i < lamps.length; i++) {
			if (lamps[i]) {
				btns[i].getBackground().setColorFilter(Color.GREEN,
						PorterDuff.Mode.MULTIPLY);
			}
		}
	}

}

package dk.cmol.arduinorgb_controller;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class SliderFragment extends Fragment {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_slider, container,
				false);

		return rootView;
	}

}

Remove button update code, FIX later


package fi.tekislauta;

import static spark.Spark.*;
import fi.tekislauta.db.*;
import com.google.gson.*;
import fi.tekislauta.models.Board;
import fi.tekislauta.models.Post;

public class Main {
    public static void main(String[] args) {
        port(1234);

        Gson gson = new Gson();

        Database db = new Database();
        get("/api", (req, res) -> {
            return db.executeQuery("SELECT * FROM Board");
        });

        get("/api/boards/:id", (req,res) -> {
            return db.executeQuery("SELECT * FROM Board WHERE abbreviation='" + req.params("id") + "'");
        });

        get("/api/posts/:id", (req,res) -> {
            return "Hello world!";
        });

        get("/api/test", (req, res) -> {
            Board b = new Board(1, "Koulu", "Kumpula", "uliopisto");
            b.addPost(new Post(1,1,12345,123,"Joonan kissa", "Joonan kissat ovat ruotsalaisia"));

            b.addPost(new Post(2,2,12345,123,"Joonan kissa", "Joonan kissat ovat ruotsalaisia"));

            return gson.toJson(b);

        });
    }
}

package fi.tekislauta;

import static spark.Spark.*;
import fi.tekislauta.db.*;
import com.google.gson.*;
import fi.tekislauta.models.Board;
import fi.tekislauta.models.Post;

public class Main {
    public static void main(String[] args) {
        port(1234);

        Gson gson = new Gson();

        Database db = new Database();
        get("/api", (req, res) -> {
            return db.executeQuery("SELECT * FROM Board");
        });

        get("/api/boards/:id", (req,res) -> {
            return db.executeQuery("SELECT * FROM Board WHERE abbreviation='" + req.params("id") + "'");
        });

        get("/api/posts/:id", (req,res) -> {
            return "Hello world!";
        });

        get("/api/test", (req, res) -> {
            res.header("Content-Type","application/json");
            Board b = new Board(1, "Koulu", "Kumpula", "uliopisto");
            b.addPost(new Post(1,1,12345,123,"Joonan kissa", "Joonan kissat ovat ruotsalaisia"));

            b.addPost(new Post(2,2,12345,123,"Joonan kissa", "Joonan kissat ovat ruotsalaisia"));

            return gson.toJson(b);

        });
    }
}

Add JSON header to test method


/*
 * Copyright 2015-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.util;

import com.sun.security.auth.module.UnixSystem;

/**
 * Fetches the user ID of the running process.
 */
public class UnixUserIdFetcher implements UserIdFetcher {
  @Override
  public long getUserId() {
    return new UnixSystem().getUid();
  }
}

/*
 * Copyright 2015-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.util;

import java.lang.reflect.Method;

/**
 * Fetches the user ID of the running process.
 */
public class UnixUserIdFetcher implements UserIdFetcher {
  @Override
  public long getUserId() {
    try {
      Class<?> cls = Class.forName("com.sun.security.auth.module.UnixSystem", true, null);
      Object unixSystem = cls.newInstance();
      Method getUid = cls.getDeclaredMethod("getUid");
      return (long) getUid.invoke(unixSystem);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

Use reflection to access UnixSystem


/*
 * Copyright 2014 - 2016 Real Logic Ltd.
 *
 * 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.agrona.generation;

/**
 * A marker annotation to tell the primitive expander not to substitute
 * The line in question
 */
public @interface DoNotSub
{
}

/*
 * Copyright 2014 - 2016 Real Logic Ltd.
 *
 * 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.agrona.generation;

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

/**
 * A marker annotation to tell the primitive expander not to substitute
 * The line in question
 */
@Retention(RetentionPolicy.SOURCE)
public @interface DoNotSub
{
}

Change retention policy on DoNotStub annotation so it is source only and not included in the class as is the default.


/*
 * Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
 */

package ai.vespa.metricsproxy.metric.model.json;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.util.List;
import java.util.logging.Logger;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_ABSENT;

/**
 * @author gjoranv
 */
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(NON_ABSENT)
@JsonPropertyOrder({ "node", "services" })
public class GenericJsonModel {
    private static Logger log = Logger.getLogger(GenericJsonModel.class.getName());

    @JsonProperty("node")
    public GenericNode node;

    @JsonProperty("services")
    public List<GenericService> services;

    public String serialize() {
        ObjectMapper mapper = JacksonUtil.createObjectMapper();
        try {
            return mapper.writeValueAsString(this);
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("Could not render metrics. Check the log for details.");
        }
    }

}

/*
 * Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
 */

package ai.vespa.metricsproxy.metric.model.json;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_ABSENT;

/**
 * @author gjoranv
 */
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(NON_ABSENT)
@JsonPropertyOrder({ "node", "services" })
public class GenericJsonModel {
    private static Logger log = Logger.getLogger(GenericJsonModel.class.getName());

    @JsonProperty("node")
    public GenericNode node;

    @JsonProperty("services")
    public List<GenericService> services;

    public String serialize() {
        ObjectMapper mapper = JacksonUtil.createObjectMapper();
        try {
            return mapper.writeValueAsString(this);
        } catch (IOException e) {
            log.log(Level.WARNING, "Got exception when rendering metrics:", e);
            throw new RuntimeException("Could not render metrics. Check the log for details.");
        }
    }

}

Use logger instead of printStackTrace


package osgi.enroute.trains.controller.api;

import org.osgi.util.promise.Promise;

/**
 * This controller controls a LOCATOR Segment
 */
public interface RFIDSegmentController extends SegmentController {

	/**
	 * Read an RFID. Resolves the promise when a new RFID is read.
	 * @return
	 */
	Promise<String> lastRFID();
}

package osgi.enroute.trains.controller.api;

import org.osgi.util.promise.Promise;

/**
 * This controller controls a LOCATOR Segment
 */
public interface RFIDSegmentController extends SegmentController {

	/**
	 * Return the last seen RFID
	 */
	String lastRFID();

	/**
	 * Read an RFID. Resolves the promise when a new RFID is read.
	 * @return
	 */
	Promise<String> nextRFID();
}

Change method lastRFID to return immediately and have nextRFID method to return promise


package org.robolectric.android.fakes;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import androidx.test.runner.MonitoringInstrumentation;
import org.robolectric.Robolectric;
import org.robolectric.android.controller.ActivityController;

public class RoboMonitoringInstrumentation extends MonitoringInstrumentation {

  @Override
  protected void specifyDexMakerCacheProperty() {
    // ignore, unnecessary for robolectric
  }

  @Override
  protected void installMultidex() {
    // ignore, unnecessary for robolectric
  }

  @Override
  public void setInTouchMode(boolean inTouch) {
    // ignore
  }

  @Override
  public void waitForIdleSync() {
    // ignore
  }

  @Override
  public Activity startActivitySync(final Intent intent) {
    ActivityInfo ai = intent.resolveActivityInfo(getTargetContext().getPackageManager(), 0);
    try {
      Class<? extends Activity> activityClass = Class.forName(ai.name).asSubclass(Activity.class);
      ActivityController<? extends Activity> controller = Robolectric.buildActivity(activityClass, intent);
      Activity activity = controller.get();
      callActivityOnCreate(activity, null);
      controller.postCreate(null);
      callActivityOnStart(activity);
      callActivityOnResume(activity);
      controller.visible().windowFocusChanged(true);
      return activity;
    } catch (ClassNotFoundException e) {
      throw new RuntimeException("Could not load activity " + ai.name, e);
    }
  }

  @Override
  public void runOnMainSync(Runnable runner) {
    runner.run();
  }
}

package org.robolectric.android.fakes;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import androidx.test.runner.MonitoringInstrumentation;
import org.robolectric.Robolectric;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.shadows.ShadowLooper;

public class RoboMonitoringInstrumentation extends MonitoringInstrumentation {

  @Override
  protected void specifyDexMakerCacheProperty() {
    // ignore, unnecessary for robolectric
  }

  @Override
  protected void installMultidex() {
    // ignore, unnecessary for robolectric
  }

  @Override
  public void setInTouchMode(boolean inTouch) {
    // ignore
  }

  @Override
  public void waitForIdleSync() {
    ShadowLooper.getShadowMainLooper().idle();
  }

  @Override
  public Activity startActivitySync(final Intent intent) {
    ActivityInfo ai = intent.resolveActivityInfo(getTargetContext().getPackageManager(), 0);
    try {
      Class<? extends Activity> activityClass = Class.forName(ai.name).asSubclass(Activity.class);
      ActivityController<? extends Activity> controller = Robolectric.buildActivity(activityClass, intent);
      Activity activity = controller.get();
      callActivityOnCreate(activity, null);
      controller.postCreate(null);
      callActivityOnStart(activity);
      callActivityOnResume(activity);
      controller.visible().windowFocusChanged(true);
      return activity;
    } catch (ClassNotFoundException e) {
      throw new RuntimeException("Could not load activity " + ai.name, e);
    }
  }

  @Override
  public void runOnMainSync(Runnable runner) {
    runner.run();
  }
}

Call through to ShadowLooper on Instrumentation.waitForIdleSync


package com.thebluealliance.androidclient.fragments;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.astuetz.PagerSlidingTabStrip;
import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.Utilities;
import com.thebluealliance.androidclient.adapters.TeamListFragmentPagerAdapter;

public class AllTeamsListFragment extends Fragment {

    private ViewPager mViewPager;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View v = inflater.inflate(R.layout.fragment_team_list_fragment_pager, container, false);
        mViewPager = (ViewPager) v.findViewById(R.id.team_pager);
        mViewPager.setAdapter(new TeamListFragmentPagerAdapter(getChildFragmentManager()));
        mViewPager.setPageMargin(Utilities.getPixelsFromDp(getActivity(), 16));

        PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) v.findViewById(R.id.team_pager_tabs);
        tabs.setViewPager(mViewPager);
        return v;
    }
}

package com.thebluealliance.androidclient.fragments;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.astuetz.PagerSlidingTabStrip;
import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.Utilities;
import com.thebluealliance.androidclient.adapters.TeamListFragmentPagerAdapter;

public class AllTeamsListFragment extends Fragment {

    private ViewPager mViewPager;
    private PagerSlidingTabStrip mTabs;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View v = inflater.inflate(R.layout.fragment_team_list_fragment_pager, container, false);
        mViewPager = (ViewPager) v.findViewById(R.id.team_pager);
        mViewPager.setPageMargin(Utilities.getPixelsFromDp(getActivity(), 16));
        mTabs = (PagerSlidingTabStrip) v.findViewById(R.id.team_pager_tabs);

        /**
         * Fix for really strange bug. Menu bar items wouldn't appear only when navigated to from 'Events' in the nav drawer
         * Bug is some derivation of this: https://code.google.com/p/android/issues/detail?id=29472
         * So set the view pager's adapter in another thread to avoid a race condition, or something.
         */
        mViewPager.post(new Runnable() {
            public void run() {
                mViewPager.setAdapter(new TeamListFragmentPagerAdapter(getChildFragmentManager()));
                mTabs.setViewPager(mViewPager);
            }
        });

        return v;
    }
}

Fix strange menu bug with teams


package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/sort-colors/
 */
public class Problem75 {
    public void sortColors(int[] nums) {
        // using counting sort
        int[] aux = new int[nums.length];
        for (int i = 0; i < aux.length; i++) {
            aux[i] = nums[i];
        }
        System.out.println("Input: " + Arrays.toString(nums));
        int size = 3;
        int[] count = new int[size];
        for (int i = 0; i < aux.length; i++) {
            count[aux[i]] += 1;
        }
        System.out.println("Count: " + Arrays.toString(count));
        for (int i = 1; i < count.length; i++) {
            count[i] = count[i-1] + count[i];
        }
        System.out.println("Sum: " + Arrays.toString(count));
        for (int i = aux.length-1; i >= 0; i--) {
            int val = aux[i];
            count[val]--;
            int idx = count[val];
            nums[idx] = val;
        }
        System.out.println("Sorted: " + Arrays.toString(nums));
    }

    public static void main(String[] args) {
        Problem75 prob = new Problem75();
//        prob.sortColors(new int[]{2});
//        prob.sortColors(new int[]{3, 2, 1, 2, 3, 1});
//        prob.sortColors(new int[]{2, 27, 22, 8, 28, 1, 30, 8, 29, 28, 15, 16, 25, 28, 23, 16, 24, 23, 17, 11, 4, 2, 2, 22, 23, 8, 29, 16, 29, 28});
//        prob.sortColors(new int[]{1, 4, 1, 2, 7, 5, 2});
    }
}

package leetcode;

/**
 * https://leetcode.com/problems/sort-colors/
 */
public class Problem75 {
    public void sortColors(int[] nums) {
        // using counting sort
        int[] aux = new int[nums.length];
        for (int i = 0; i < aux.length; i++) {
            aux[i] = nums[i];
        }
        int size = 3;
        int[] count = new int[size];
        for (int i = 0; i < aux.length; i++) {
            count[aux[i]] += 1;
        }
        for (int i = 1; i < count.length; i++) {
            count[i] = count[i-1] + count[i];
        }
        for (int i = aux.length-1; i >= 0; i--) {
            int val = aux[i];
            count[val]--;
            int idx = count[val];
            nums[idx] = val;
        }
    }
}

Clean up problem 75 solution


package by.triumgroup.recourse.configuration.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;

import javax.sql.DataSource;

@Configuration
@EnableResourceServer
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {

    private final DataSource dataSource;

    @Autowired
    public ResourceServerConfiguration(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Bean
    public TokenStore tokenStore() {
        return new JdbcTokenStore(dataSource);
    }

    @Override
    public void configure(ResourceServerSecurityConfigurer resources) {
        resources
                .tokenStore(tokenStore());
        resources.stateless(false);
    }

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                    .antMatchers("/**").permitAll()
                    .anyRequest().authenticated();
    }
}

package by.triumgroup.recourse.configuration.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;

import javax.sql.DataSource;

@Configuration
@EnableResourceServer
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {

    private final DataSource dataSource;

    @Autowired
    public ResourceServerConfiguration(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Bean
    public TokenStore tokenStore() {
        return new JdbcTokenStore(dataSource);
    }

    @Override
    public void configure(ResourceServerSecurityConfigurer resources) {
        resources
                .tokenStore(tokenStore());
        resources.stateless(false);
    }

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                    // TODO Need to be configured
                    .antMatchers("/**").permitAll()
                    .anyRequest().authenticated();
    }
}

Add TODO task to security configuration.


/*
 Copyright 2014 Etienne Studer

 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 nu.studer.gradle.jooq;

/**
 * jOOQ comes in different editions, which are published
 * under different group ids. The artifact names and versions
 * are the same for all editions.
 */
public enum JooqEdition {

    OSS("org.jooq"),
    PRO("org.jooq.pro"),
    PRO_JAVA_8("org.jooq.pro-java-8"),
    PRO_JAVA_6("org.jooq.pro-java-6"),
    TRIAL("org.jooq.trial"),
    TRIAL_JAVA_8("org.jooq.trial-java-8"),
    TRIAL_JAVA_6("org.jooq.trial-java-6");

    private final String groupId;

    JooqEdition(String groupId) {
        this.groupId = groupId;
    }

    public String getGroupId() {
        return groupId;
    }

}

/*
 Copyright 2014 Etienne Studer

 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 nu.studer.gradle.jooq;

/**
 * jOOQ comes in different editions, which are published
 * under different group ids. The artifact names and versions
 * are the same for all editions.
 */
public enum JooqEdition {

    OSS("org.jooq"),
    PRO("org.jooq.pro"),
    PRO_JAVA_11("org.jooq.pro-java-11"),
    PRO_JAVA_8("org.jooq.pro-java-8"),
    PRO_JAVA_6("org.jooq.pro-java-6"),
    TRIAL("org.jooq.trial"),
    TRIAL_JAVA_11("org.jooq.trial-java-11"),
    TRIAL_JAVA_8("org.jooq.trial-java-8"),
    TRIAL_JAVA_6("org.jooq.trial-java-6");

    private final String groupId;

    JooqEdition(String groupId) {
        this.groupId = groupId;
    }

    public String getGroupId() {
        return groupId;
    }

}

Add support for new jOOQ 3.15 distributions


package com.surfsoftconsulting.clipper.racetracker.controller;

/*
 * Copyright 2017 Phil Haigh
 *
 * 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.
 */

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

@RestController
public class HealthCheckController {

    @RequestMapping(method=GET, path="/")
    public void healthCheck() {}

}

package com.surfsoftconsulting.clipper.racetracker.controller;

/*
 * Copyright 2017 Phil Haigh
 *
 * 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.
 */

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

@RestController
public class HealthCheckController {

    @RequestMapping(method=GET, path="/healthcheck")
    public void healthCheck() {}

}

Fix URL of healthcheck endpoint


package org.teiid.authoring.client.perspectives;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;

import org.uberfire.client.annotations.Perspective;
import org.uberfire.client.annotations.WorkbenchPerspective;
import org.uberfire.mvp.impl.DefaultPlaceRequest;
import org.uberfire.workbench.model.PanelType;
import org.uberfire.workbench.model.PerspectiveDefinition;
import org.uberfire.workbench.model.impl.PartDefinitionImpl;
import org.uberfire.workbench.model.impl.PerspectiveDefinitionImpl;

// /**
// * A Perspective to show File Explorer
// */
@ApplicationScoped
@WorkbenchPerspective(identifier = "MainPerspective", isDefault = true)
public class MainPerspective {

    private PerspectiveDefinition perspective;

    @PostConstruct
    public void init() {
        buildPerspective();
    }

    @Perspective
    public PerspectiveDefinition getPerspective() {
        return this.perspective;
    }

    public PerspectiveDefinition buildPerspective() {
        perspective = new PerspectiveDefinitionImpl( PanelType.ROOT_STATIC );
        perspective.setTransient(true);
        perspective.setName("MainPerspective");
        perspective.getRoot().addPart(new PartDefinitionImpl(new DefaultPlaceRequest("DataSourcesScreen")));

//        PanelDefinitionImpl westPanel = new PanelDefinitionImpl(PanelType.MULTI_LIST);
//        perspective.getRoot().insertChild(Position.WEST, westPanel);
//        westPanel.setWidth(250);
//        westPanel.addPart(
//                new PartDefinitionImpl(
//                        new DefaultPlaceRequest("MoodScreen")));

        return perspective;
    }
}

package org.teiid.authoring.client.perspectives;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;

import org.uberfire.client.annotations.Perspective;
import org.uberfire.client.annotations.WorkbenchPerspective;
import org.uberfire.mvp.impl.DefaultPlaceRequest;
import org.uberfire.workbench.model.PanelType;
import org.uberfire.workbench.model.PerspectiveDefinition;
import org.uberfire.workbench.model.impl.PartDefinitionImpl;
import org.uberfire.workbench.model.impl.PerspectiveDefinitionImpl;

// /**
// * A Perspective to show File Explorer
// */
@ApplicationScoped
@WorkbenchPerspective(identifier = "MainPerspective", isDefault = true)
public class MainPerspective {

    @Perspective
    public PerspectiveDefinition buildPerspective() {
        PerspectiveDefinition perspective = new PerspectiveDefinitionImpl( PanelType.ROOT_STATIC );
        perspective.setTransient(true);
        perspective.setName("MainPerspective");
        perspective.getRoot().addPart(new PartDefinitionImpl(new DefaultPlaceRequest("DataSourcesScreen")));

//        PanelDefinitionImpl westPanel = new PanelDefinitionImpl(PanelType.MULTI_LIST);
//        perspective.getRoot().insertChild(Position.WEST, westPanel);
//        westPanel.setWidth(250);
//        westPanel.addPart(
//                new PartDefinitionImpl(
//                        new DefaultPlaceRequest("MoodScreen")));

        return perspective;
    }
}

Fix perspective initialization issue when clicking on top menu navbar


package org.ligi.snackengage;

import android.Manifest;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;

import org.junit.Test;
import org.ligi.snackengage.conditions.connectivity.IsConnectedViaWiFiOrUnknown;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;

public class TheConnectedViaWifiSnackConditions extends BaseTest {

    @Test
    public void shouldReturnTrueForWifi() throws Exception {
        assertThat(setupSnack(ConnectivityManager.TYPE_WIFI)).isTrue();
    }

    @Test
    public void shouldReturnFalseForMobile() throws Exception {
        assertThat(setupSnack(ConnectivityManager.TYPE_MOBILE)).isFalse();
    }

    private boolean setupSnack(final int networkType) {
        final IsConnectedViaWiFiOrUnknown tested = new IsConnectedViaWiFiOrUnknown();

        when(mockAndroidContext.checkCallingOrSelfPermission(Manifest.permission.ACCESS_NETWORK_STATE)).thenReturn(PackageManager.PERMISSION_GRANTED);

        when(mockNetwork.getType()).thenReturn(networkType);
        when(mockNetwork.isConnectedOrConnecting()).thenReturn(true);

        return tested.isAppropriate(mockSnackContext, null);
    }

}

package org.ligi.snackengage;

import android.Manifest;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;

import org.junit.Test;
import org.ligi.snackengage.conditions.connectivity.IsConnectedViaWiFiOrUnknown;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;

public class TheConnectedViaWifiSnackConditions extends BaseTest {

    @Test
    public void shouldReturnTrueForWifi() {
        assertThat(setupSnack(ConnectivityManager.TYPE_WIFI)).isTrue();
    }

    @Test
    public void shouldReturnFalseForMobile() {
        assertThat(setupSnack(ConnectivityManager.TYPE_MOBILE)).isFalse();
    }

    private boolean setupSnack(final int networkType) {
        final IsConnectedViaWiFiOrUnknown tested = new IsConnectedViaWiFiOrUnknown();

        when(mockAndroidContext.checkCallingOrSelfPermission(Manifest.permission.ACCESS_NETWORK_STATE)).thenReturn(PackageManager.PERMISSION_GRANTED);

        when(mockNetwork.getType()).thenReturn(networkType);
        when(mockNetwork.isConnectedOrConnecting()).thenReturn(true);

        return tested.isAppropriate(mockSnackContext, null);
    }

}

Remove unneeded exception in test.


#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package};

import org.exoplatform.services.rest.resource.ResourceContainer;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

/**
 * Created by eXo Platform MEA on 06/05/14.
 *
 * @author Marwen Trabelsi
 */

@Path("/my-resource")
public class MyRestResource implements ResourceContainer {

  @GET
  @Path("/get/{name}")
  public String get(@PathParam("word") String word) {
    return "Hello " + word;
  }

}

#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package};

import org.exoplatform.services.rest.resource.ResourceContainer;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

/**
 * Created by WiseBrains on 06/05/14.
 *
 * The MyRestResource class represents a RESTful GateIn
 * resource container.
 *
 * @author Marwen Trabelsi
 */

@Path("/my-resource")
public class MyRestResource implements ResourceContainer {

  /**
   * A GET style method that returns a {@code String} object that
   * formed of
Hello
 along with a
word
 forwarded
   * to the the method endpoint URL as a {@code PathParam}.
   */
  @GET
  @Path("/get/{name}")
  public String get(@PathParam("word") String word) {
    return "Hello " + word;
  }

}

Add JavaDoc to GateIn Rest resource component


package io.freefair.gradle.plugins.github;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;

/**
 * @author Lars Grefer
 */
public class GithubPackageRegistryMavenPublishPlugin implements Plugin<Project> {
    @Override
    public void apply(Project project) {

        project.getPlugins().apply(MavenPublishPlugin.class);
        project.getPlugins().apply(GithubPomPlugin.class);

        GithubExtension githubExtension = project.getRootProject().getExtensions().getByType(GithubExtension.class);

        project.afterEvaluate(p -> p.getExtensions().getByType(PublishingExtension.class)
                .getRepositories()
                .maven(githubRepo -> {
                    String owner = githubExtension.getOwner().get();
                    githubRepo.setName("GitHub " + owner + " Apache Maven Packages");
                    githubRepo.setUrl("https://maven.pkg.github.com/" + githubExtension.getSlug().get());

                    if (githubExtension.getUsername().isPresent() && githubExtension.getToken().isPresent()) {
                        githubRepo.credentials(passwordCredentials -> {
                            passwordCredentials.setUsername(githubExtension.getUsername().get());
                            passwordCredentials.setPassword(githubExtension.getToken().get());
                        });
                    }

                }));

    }
}

package io.freefair.gradle.plugins.github;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;

/**
 * @author Lars Grefer
 */
public class GithubPackageRegistryMavenPublishPlugin implements Plugin<Project> {
    @Override
    public void apply(Project project) {

        project.getPlugins().apply(MavenPublishPlugin.class);
        project.getPlugins().apply(GithubPomPlugin.class);

        GithubExtension githubExtension = project.getRootProject().getExtensions().getByType(GithubExtension.class);

        project.afterEvaluate(p -> p.getExtensions().getByType(PublishingExtension.class)
                .getRepositories()
                .maven(githubRepo -> {
                    githubRepo.setName("GithubPackageRegistry");
                    githubRepo.setUrl("https://maven.pkg.github.com/" + githubExtension.getSlug().get());

                    if (githubExtension.getUsername().isPresent() && githubExtension.getToken().isPresent()) {
                        githubRepo.credentials(passwordCredentials -> {
                            passwordCredentials.setUsername(githubExtension.getUsername().get());
                            passwordCredentials.setPassword(githubExtension.getToken().get());
                        });
                    }

                }));

    }
}

Use a better name for the gihub publishing repository


/**
 * Copyright (C) 2016 Red Hat, 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.redhat.ipaas.rest.v1.handler.exception;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@Provider
public class IPaasServerExceptionMapper implements javax.ws.rs.ext.ExceptionMapper<ClassNotFoundException> {

	private static final Logger LOG = LoggerFactory.getLogger(IPaasServerExceptionMapper.class);

	@Override
	public Response toResponse(ClassNotFoundException e) {
		LOG.error(e.getMessage(),e);
		RestError error = new RestError("Internal Server Exception. " + e.getMessage(), "Please contact the administrator and file a bug report", 500);
		return Response.status(error.errorCode).entity(error).build();
	}

}

/**
 * Copyright (C) 2016 Red Hat, 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.redhat.ipaas.rest.v1.handler.exception;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@Provider
public class IPaasServerExceptionMapper implements javax.ws.rs.ext.ExceptionMapper<Exception> {

	private static final Logger LOG = LoggerFactory.getLogger(IPaasServerExceptionMapper.class);

	@Override
	public Response toResponse(Exception e) {
		LOG.error(e.getMessage(),e);
		RestError error = new RestError("Internal Server Exception. " + e.getMessage(), "Please contact the administrator and file a bug report", 500);
		return Response.status(error.errorCode).entity(error).build();
	}

}

Return 500 errors for all unmapped exceptions


package controllers;

import models.Game;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.platform_read;

import java.util.List;

public class PlatformController extends Controller {

    public static Result read(final String platformName) {
        if (platformName == null) {
            return notFound();
        }
        List<Game> games = getGamesByPlatform(platformName);
        return ok(platform_read.render(platformName, games));
    }

    public static List<Game> getGamesByPlatform(final String platformName) {
        return Game.finder.where().ieq("platforms.name", platformName).findList();
    }

}

package controllers;

import models.Game;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.platform_read;

import java.util.List;

public class PlatformController extends Controller {

    public static Result read(final String platformName) {
        if (platformName == null) {
            return notFound();
        }
        List<Game> games = getGamesByPlatform(platformName);
        return ok(platform_read.render(platformName, games));
    }

    public static List<Game> getGamesByPlatform(final String platformName) {
        return Game.finder.where().ieq("platforms.name", platformName).order("title").findList();
    }

}

Order one cc by game title


package common.pages;

import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Image;

public class ImageData extends Base {

    private final Image image;

    private ImageData(final Image image) {
        this.image = image;
    }

    public static ImageData of(final Image image) {
        return new ImageData(image);
    }

    public String getThumbImage() {
        return nullIfEmpty(image.getUrl());
    }

    public String getBigImage() {
        return nullIfEmpty(image.getUrl());
    }

    public String getPlaceholderImage() {
        return "http://placehold.it/350x150";
    }

    private String nullIfEmpty(final String s) {
        if(s.isEmpty())
            return null;
        else
            return s;
    }
}

package common.pages;

import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Image;

import static org.apache.commons.lang3.StringUtils.trimToNull;

public class ImageData extends Base {

    private final Image image;

    private ImageData(final Image image) {
        this.image = image;
    }

    public static ImageData of(final Image image) {
        return new ImageData(image);
    }

    public String getThumbImage() {
        return trimToNull(image.getUrl());
    }

    public String getBigImage() {
        return trimToNull(image.getUrl());
    }

    public String getPlaceholderImage() {
        return "http://placehold.it/350x150";
    }
}

Remove nullIfEmpty method and use StringUtils instead


package com.codenvy.ide.ext.datasource.client.common;

import com.google.gwt.user.cellview.client.CellTable;

public interface CellTableResources extends CellTable.Resources {

    public interface CellTableStyle extends CellTable.Style {
    }

    @Source({"CellTable.css", "com/codenvy/ide/api/ui/style.css"})
    CellTableStyle cellTableStyle();
}

package com.codenvy.ide.ext.datasource.client.common;

import com.google.gwt.user.cellview.client.CellTable;

public interface CellTableResources extends CellTable.Resources {

    public interface CellTableStyle extends CellTable.Style {

        String infoHeader();

        String queryReminder();

        String csvButton();

        String infoHeaderTitle();
    }

    @Source({"CellTable.css", "com/codenvy/ide/api/ui/style.css"})
    CellTableStyle cellTableStyle();
}

Add accessors to result headers styles


package org.wildfly.jaxrs;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

/**
 * Created by Muhammad on 11/11/2015.
 */

// This class is located at "/helloworld"
@Path("/helloworld")
public class HelloWorldResource {
    // These method will process HTTP GET requests
    // The Java method will produce content identified by the MIME Media

    /**
     * Method to return text/plain request
     * @return
     */
    @GET
    @Produces("application/json")
    public String getJsonMessage() {
        // return some cliched textual content
        return "{\"info\": \"Welcome to the demo of Wildfly, Java EE7 and AngularJS. This message is retrieved" +
                "serve using REST API and consume by AngularJS.\"}";
    }

}

package org.wildfly.jaxrs;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

/**
 * Created by Muhammad on 11/11/2015.
 */

// This class is located at "/helloworld"
@Path("/helloworld")
public class HelloWorldResource {
    // These method will process HTTP GET requests
    // The Java method will produce content identified by the MIME Media

    /**
     * Method to return text/plain request
     * @return
     */
    @GET
    @Produces("application/json")
    public String getJsonMessage() {
        // return some cliched textual content
        return "{\"info\": \"Welcome to the demo of Wildfly, Java EE7 and AngularJS. This message is " +
                "served using REST API and consumed by AngularJS.\"}";
    }

}

Fix grammar of the sentence for welcome page.


package net.chrizzly.csharp4netbeans.filetypes.cs.parser.reformatting;

import javax.swing.text.BadLocationException;
import org.netbeans.modules.editor.indent.spi.Context;
import org.netbeans.modules.editor.indent.spi.ExtraLock;
import org.netbeans.modules.editor.indent.spi.ReformatTask;
import org.openide.awt.StatusDisplayer;

/**
 *
 * @author chrl
 */
public class CsReformatTask implements ReformatTask {

    private Context context;

    public CsReformatTask(Context context) {
        this.context = context;
    }

    @Override
    public void reformat() throws BadLocationException {
        StatusDisplayer.getDefault().setStatusText("We will format this now...");
    }

    @Override
    public ExtraLock reformatLock() {
        return null;
    }

}

package net.chrizzly.csharp4netbeans.filetypes.cs.parser.reformatting;

import java.util.List;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import net.chrizzly.csharp4netbeans.utils.MiscUtil;
import org.netbeans.modules.editor.indent.spi.Context;
import org.netbeans.modules.editor.indent.spi.ExtraLock;
import org.netbeans.modules.editor.indent.spi.ReformatTask;
import org.openide.awt.StatusDisplayer;

/**
 *
 * @author chrl
 */
public class CsReformatTask implements ReformatTask {

    private final Context context;

    public CsReformatTask(Context context) {
        this.context = context;
    }

    @Override
    public void reformat() throws BadLocationException {
        StatusDisplayer.getDefault().setStatusText("We will format this now...");
        Document document = context.document();
        String fileContent = document.getText(document.getStartPosition().getOffset(),
                document.getEndPosition().getOffset());
        String fileFormattedFinal = formatFile(fileContent, 4);
        int length = document.getLength();
        document.remove(0, length);
        document.insertString(0, fileFormattedFinal, null);
    }

    @Override
    public ExtraLock reformatLock() {
        return null;
    }

    private static String formatFile(String fileContent, int spacesToIncrement) {
        short currentSpacesToUse = 0;

        StringBuilder sbResult = new StringBuilder();

        List<String> listLines = MiscUtil.getLinesFromFileContent(fileContent);
        for (String line : listLines) {
            int openTagsAmount = MiscUtil.getOpenSymbolsAmount(line);

            String amountSeparatorChars;
            if (openTagsAmount > 0) {
                amountSeparatorChars = MiscUtil.getAmountSeparatorChars(currentSpacesToUse);
                currentSpacesToUse += spacesToIncrement * openTagsAmount;
            } else {
                currentSpacesToUse += spacesToIncrement * openTagsAmount;
                amountSeparatorChars = MiscUtil.getAmountSeparatorChars(currentSpacesToUse);
            }

            sbResult.append(amountSeparatorChars).append(line.trim()).append(MiscUtil.LINE_SEPARATOR);
        }

        return sbResult.toString().substring(0, sbResult.length() - 1); //substring to remove the last LINE_SEPARATOR
    }
}

Copy over the reformat code from a fork of pedro.


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

public class Command {

    private String value;

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}

Add header and remove final blank space


package com.example.android.waitlist.data;

import android.provider.BaseColumns;

public class WaitlistContract {

    // TODO (1) Create an inner class named WaitlistEntry class that implements the BaseColumns interface

        // TODO (2) Inside create a static final members for the table name and each of the db columns
        // TABLE_NAME -> waitlist;
        // COLUMN_GUEST_NAME -> guestName
        // COLUMN_PARTY_SIZE -> partySize
        // COLUMN_TIMESTAMP -> timestamp

}

package com.example.android.waitlist.data;

import android.provider.BaseColumns;

public class WaitlistContract {

    private WaitlistContract(){};
    // TODO (1) Create an inner class named WaitlistEntry class that implements the BaseColumns interface

        // TODO (2) Inside create a static final members for the table name and each of the db columns
        // TABLE_NAME -> waitlist;
        // COLUMN_GUEST_NAME -> guestName
        // COLUMN_PARTY_SIZE -> partySize
        // COLUMN_TIMESTAMP -> timestamp
    public static final class WaitlistEntry implements BaseColumns {
            public static final String TABLE_NAME = "waitlist";
            public static final String COLUMN_GUEST_NAME = "guestName";
            public static final String COLUMN_PARTY_SIZE = "partySize";
            public static final String COLUMN_TIMESTAMP = "timestamp";
    }

}

Complete TODOs for T07.01 CreateAContract exercise


package org.ovirt.engine.core.common.queries;

import org.ovirt.engine.core.compat.Guid;
import org.ovirt.engine.core.compat.Version;

public class GetFilteredAttachableDisksParameters extends GetAllAttachableDisksForVmQueryParameters {

    private int os;

    private Version vdsGroupCompatibilityVersion;

    public GetFilteredAttachableDisksParameters() {
        super();
    }

    public GetFilteredAttachableDisksParameters(Guid storagePoolId) {
        super(storagePoolId);
    }

    public int getOs() {
        return os;
    }

    public void setOs(int os) {
        this.os = os;
    }

    public Version getVdsGroupCompatibilityVersion() {
        return vdsGroupCompatibilityVersion;
    }

    public void setVdsGroupCompatibilityVersion(Version vdsGroupCompatibilityVersion) {
        this.vdsGroupCompatibilityVersion = vdsGroupCompatibilityVersion;
    }
}

package org.ovirt.engine.core.common.queries;

import org.ovirt.engine.core.compat.Guid;
import org.ovirt.engine.core.compat.Version;

public class GetFilteredAttachableDisksParameters extends GetAllAttachableDisksForVmQueryParameters {

    private static final long serialVersionUID = 4092810692277463140L;

    private int os;

    private Version vdsGroupCompatibilityVersion;

    public GetFilteredAttachableDisksParameters() {
        super();
    }

    public GetFilteredAttachableDisksParameters(Guid storagePoolId) {
        super(storagePoolId);
    }

    public int getOs() {
        return os;
    }

    public void setOs(int os) {
        this.os = os;
    }

    public Version getVdsGroupCompatibilityVersion() {
        return vdsGroupCompatibilityVersion;
    }

    public void setVdsGroupCompatibilityVersion(Version vdsGroupCompatibilityVersion) {
        this.vdsGroupCompatibilityVersion = vdsGroupCompatibilityVersion;
    }
}

Add missing serial version id


package org.panda_lang.panda.framework.language.interpreter.parser.implementation.general.expression.updated.subparsers;

public class DefaultSubparserPriorities {

    public static final double SINGLE = 0;

    public static final double AFTER_SINGLE = 1;

    public static final double DYNAMIC = 2;

    public static final double AFTER_DYNAMIC = 3;

}

package org.panda_lang.panda.framework.language.interpreter.parser.implementation.general.expression.updated.subparsers;

public class DefaultSubparserPriorities {

    public static final double DYNAMIC = 1;

    public static final double SINGLE = 2;

}

Swap DYNAMIC parsers with SINGLE


package com.yuyakaido.android.cardstackview.internal;

import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;

import com.yuyakaido.android.cardstackview.CardStackLayoutManager;

public class CardStackDataObserver extends RecyclerView.AdapterDataObserver {

    private final RecyclerView recyclerView;

    public CardStackDataObserver(RecyclerView recyclerView) {
        this.recyclerView = recyclerView;
    }

    @Override
    public void onChanged() {
        CardStackLayoutManager manager = getCardStackLayoutManager();
        manager.setTopPosition(0);
    }

    @Override
    public void onItemRangeChanged(int positionStart, int itemCount) {
        // Do nothing
    }

    @Override
    public void onItemRangeChanged(int positionStart, int itemCount, @Nullable Object payload) {
        // Do nothing
    }

    @Override
    public void onItemRangeInserted(int positionStart, int itemCount) {
        // Do nothing
    }

    @Override
    public void onItemRangeRemoved(int positionStart, int itemCount) {
        CardStackLayoutManager manager = getCardStackLayoutManager();
        if (positionStart == 0) {
            manager.setTopPosition(0);
        }
        manager.removeAllViews();
    }

    @Override
    public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
        // Do nothing
    }

    private CardStackLayoutManager getCardStackLayoutManager() {
        RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
        if (manager instanceof CardStackLayoutManager) {
            return (CardStackLayoutManager) manager;
        }
        throw new IllegalStateException("CardStackView must be set CardStackLayoutManager.");
    }

}

package com.yuyakaido.android.cardstackview.internal;

import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;

import com.yuyakaido.android.cardstackview.CardStackLayoutManager;

public class CardStackDataObserver extends RecyclerView.AdapterDataObserver {

    private final RecyclerView recyclerView;

    public CardStackDataObserver(RecyclerView recyclerView) {
        this.recyclerView = recyclerView;
    }

    @Override
    public void onChanged() {
        CardStackLayoutManager manager = getCardStackLayoutManager();
        manager.setTopPosition(0);
    }

    @Override
    public void onItemRangeChanged(int positionStart, int itemCount) {
        // Do nothing
    }

    @Override
    public void onItemRangeChanged(int positionStart, int itemCount, @Nullable Object payload) {
        // Do nothing
    }

    @Override
    public void onItemRangeInserted(int positionStart, int itemCount) {
        // Do nothing
    }

    @Override
    public void onItemRangeRemoved(int positionStart, int itemCount) {
        CardStackLayoutManager manager = getCardStackLayoutManager();
        if (positionStart == 0) {
            manager.setTopPosition(0);
        }
        manager.removeAllViews();
    }

    @Override
    public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
        CardStackLayoutManager manager = getCardStackLayoutManager();
        manager.removeAllViews();
    }

    private CardStackLayoutManager getCardStackLayoutManager() {
        RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
        if (manager instanceof CardStackLayoutManager) {
            return (CardStackLayoutManager) manager;
        }
        throw new IllegalStateException("CardStackView must be set CardStackLayoutManager.");
    }

}

Refresh all views when invoking move action


package com.sandjelkovic.dispatch.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;

@SpringBootApplication
@EnableConfigServer
public class DispatchdConfigurationApplication {

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

package com.sandjelkovic.dispatch.config;

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

@SpringBootApplication
//@EnableConfigServer
public class DispatchdConfigurationApplication {

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

Fix failing test by temporarily removing Config server activation


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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;

import com.redhat.ceylon.eclipse.core.typechecker.ProjectPhasedUnit;
import com.redhat.ceylon.eclipse.core.vfs.ResourceVirtualFile;

public class ProjectSourceFile extends SourceFile implements IResourceAware {

    public ProjectSourceFile(ProjectPhasedUnit phasedUnit) {
        super(phasedUnit);
    }

    @Override
    public ProjectPhasedUnit getPhasedUnit() {
        return (ProjectPhasedUnit) super.getPhasedUnit();
    }

    @Override
    public IProject getProjectResource() {
        return getPhasedUnit().getProjectResource();
    }

    @Override
    public IFile getFileResource() {
        return (IFile)((ResourceVirtualFile) (getPhasedUnit().getUnitFile())).getResource();
    }

    @Override
    public IFolder getRootFolderResource() {
        return null;
    }
}

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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;

import com.redhat.ceylon.eclipse.core.typechecker.ProjectPhasedUnit;
import com.redhat.ceylon.eclipse.core.vfs.ResourceVirtualFile;

public class ProjectSourceFile extends SourceFile implements IResourceAware {

    public ProjectSourceFile(ProjectPhasedUnit phasedUnit) {
        super(phasedUnit);
    }

    @Override
    public ProjectPhasedUnit getPhasedUnit() {
        return (ProjectPhasedUnit) super.getPhasedUnit();
    }

    @Override
    public IProject getProjectResource() {
        return getPhasedUnit().getProjectResource();
    }

    @Override
    public IFile getFileResource() {
        return getPhasedUnit().getSourceFileResource();
    }

    @Override
    public IFolder getRootFolderResource() {
        return getPhasedUnit().getSourceFolderResource();
    }
}

Correct implementation of the IResourceAware methods