package name.abuchen.portfolio.util;

public class Isin
{
    private static final String CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //$NON-NLS-1$
    public static final String PATTERN = "[A-Z]{2}[A-Z0-9]{9}\\d"; //$NON-NLS-1$

    private Isin()
    {
    }

    public static final boolean isValid(String isin) // NOSONAR
    {
        if (isin == null || isin.length() != 12)
            return false;

        int sum = 0;
        boolean even = false;

        for (int ii = 11; ii >= 0; ii--)
        {
            int v = CHARACTERS.indexOf(isin.charAt(ii));
            if (v < 0)
                return false;

            int digit = v % 10 * (even ? 2 : 1);
            sum += digit > 9 ? digit - 9 : digit;
            even = !even;

            if (v >= 10)
            {
                digit = v / 10 * (even ? 2 : 1);
                sum += digit > 9 ? digit - 9 : digit;
                even = !even;
            }
        }

        return sum % 10 == 0;
    }
}

package name.abuchen.portfolio.util;

public class Isin
{
    private static final String CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //$NON-NLS-1$
    public static final String PATTERN = "[A-Z]{2}[A-Z0-9]{9}\\d"; //$NON-NLS-1$

    private Isin()
    {
    }

    public static final boolean isValid(String isin) // NOSONAR
    {
        if (isin == null || isin.length() != 12)
            return false;

        int sum = 0;
        boolean even = false;

        for (int ii = 11; ii >= 0; ii--)
        {
            int v = CHARACTERS.indexOf(isin.charAt(ii));
            if (v < 0)
                return false;

            int digit = v % 10 * (even ? 2 : 1);
            sum += digit > 9 ? digit - 9 : digit;
            even = !even;

            if (v >= 10)
            {
                digit = v / 10 * (even ? 2 : 1);
                sum += digit;
                even = !even;
            }
        }

        return sum % 10 == 0;
    }
}

Remove unused conditon which cant hold anyway


package org.pentaho.di.run.sortedmerge;

import junit.framework.TestCase;

import org.pentaho.di.core.Result;
import org.pentaho.di.core.logging.LogWriter;
import org.pentaho.di.run.AllRunTests;
import org.pentaho.di.run.TimedTransRunner;

public class RunSortedMerge extends TestCase
{
    public void test_SORTED_MERGE_00()
    {
        System.out.println();
        System.out.println("SORTED MERGE");
        System.out.println("==================");
    }

    public void test_SORTED_MERGE_01_SIMPLE() throws Exception
    {
        TimedTransRunner timedTransRunner = new TimedTransRunner(
                "test/org/pentaho/di/run/sortedmerge/SortedMergeSimple.ktr",
                LogWriter.LOG_LEVEL_ERROR,
                AllRunTests.getOldTargetDatabase(),
                AllRunTests.getNewTargetDatabase(),
                1000000
            );
        timedTransRunner.runOldAndNew();

        be.ibridge.kettle.core.Result oldResult = timedTransRunner.getOldResult();
        assertTrue(oldResult.getNrErrors()==0);

        Result newResult = timedTransRunner.getNewResult();
        assertTrue(newResult.getNrErrors()==0);
    }
}

Update of sorted merge step test case

Update of sorted merge step test case

git-svn-id: 51b39fcfd0d3a6ea7caa15377cad4af13b9d2664@4016 5fb7f6ec-07c1-534a-b4ca-9155e429e800


package org.tigris.subversion.lib;

/**
 * ====================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 *
 */

public class StatusKind
{
    public final static int NONE=1;
    public final static int NORMAL=2;
    public final static int ADDED=3;
    public final static int ABSENT=4;
    public final static int DELETED=5;
    public final static int REPLACED=6;
    public final static int MODIFIED=7;
    public final static int MERGED=8;
    public final static int CONFLICTED=9;

    public final int kind;

    public StatusKind(int kind)
	{
	    this.kind = kind;
	}
}

package org.tigris.subversion.lib;

/**
 * ====================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 *
 */

public class StatusKind
{
    public final static int NONE=1;
    public final static int NORMAL=2;
    public final static int ADDED=3;
    public final static int ABSENT=4;
    public final static int DELETED=5;
    public final static int REPLACED=6;
    public final static int MODIFIED=7;
    public final static int MERGED=8;
    public final static int CONFLICTED=9;

    private int kind = NONE;

    public StatusKind(int kind)
	{
	    super();
	    this.kind = kind;
	}

    public StatusKind()
	{
	    this(NONE);
	}

    public void setKind(int _kind)
	{
	    kind = _kind;
	}

    public int getKind()
	{
	    return kind;
	}
}

Integrate the hashtable Unit testcases.

Integrate the hashtable Unit testcases.

* tests/AllTests.java (suite): added HashtableTests


package com.cloudrobotics.hello_world_client;

import cloudrobotics.hello_world.v1alpha1.K8sHelloWorldGrpc;
import cloudrobotics.hello_world.v1alpha1.Service;
import io.grpc.ManagedChannelBuilder;
import java.util.logging.Logger;

/** */
final class Main {

  private static final Logger logger = Logger.getLogger(Main.class.getName());

  public static void main(String[] args) {
    K8sHelloWorldGrpc.K8sHelloWorldBlockingStub stub =
        K8sHelloWorldGrpc.newBlockingStub(
            ManagedChannelBuilder.forAddress("localhost", 50051).usePlaintext().build());
    Service.HelloWorld world =
        stub.get(Service.GetHelloWorldRequest.newBuilder().setName("foo").build());
    System.out.println(world.getMetadata().getResourceVersion());
  }
}

package com.cloudrobotics.hello_world_client;

import cloudrobotics.hello_world.v1alpha1.K8sHelloWorldGrpc;
import cloudrobotics.hello_world.v1alpha1.Service;
import io.grpc.ManagedChannelBuilder;
import java.util.logging.Logger;

/** */
final class Main {

  private static final Logger logger = Logger.getLogger(Main.class.getName());

  public static void main(String[] args) {
    K8sHelloWorldGrpc.K8sHelloWorldBlockingStub stub =
        K8sHelloWorldGrpc.newBlockingStub(
            ManagedChannelBuilder.forAddress("localhost", 50051).usePlaintext().build());
    Service.CreateHelloWorldRequest.Builder req = Service.CreateHelloWorldRequest.newBuilder();
    req.getObjectBuilder().getMetadataBuilder().setName("foo");
    stub.create(req.build());
    Service.HelloWorld world =
        stub.get(Service.GetHelloWorldRequest.newBuilder().setName("foo").build());
    System.out.println(world.getMetadata().getResourceVersion());
    stub.delete(Service.DeleteHelloWorldRequest.newBuilder().setName("foo").build());
  }
}

Add coverage the Hello World client example.

This is now free-standing and also covers edge cases like timestamps.

b/124437335

Change-Id: I9496504b638ae6af3885a20aeedf18e267aca683
GitOrigin-RevId: b7c8694f2f920371ee228bb53a6e499e3b727783


package org.rundeck.api;

import org.rundeck.api.RundeckApiException;
import org.rundeck.api.RundeckApiException.RundeckApiLoginException;
import org.rundeck.api.RundeckApiException.RundeckApiTokenException;
import org.rundeck.api.RundeckClient;
import org.rundeck.api.domain.RundeckHistory;
import org.rundeck.api.parser.HistoryParser;
import org.rundeck.api.util.AssertUtil;

public class RundeckMonitorClient extends RundeckClient{

	private static final long serialVersionUID = 6744841390473909439L;

	public RundeckMonitorClient(String url, String login, String password)
			throws IllegalArgumentException {
		super(url, login, password);
	}

	@Override
	public RundeckHistory getHistory( final String project, final String statut, final Long max, final Long offset) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {

		AssertUtil.notBlank(project, "project is mandatory to get the history !"); //$NON-NLS-1$

		return new ApiCall(this).get( new ApiPathBuilder( "/history" ).param( "project", project).param( "statFilter", statut ).param( "max", max ).param("offset", offset), new HistoryParser( "result/events" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
	}
}

package org.rundeck.api;

import org.rundeck.api.RundeckApiException;
import org.rundeck.api.RundeckApiException.RundeckApiLoginException;
import org.rundeck.api.RundeckApiException.RundeckApiTokenException;
import org.rundeck.api.RundeckClient;
import org.rundeck.api.domain.RundeckHistory;
import org.rundeck.api.parser.HistoryParser;
import org.rundeck.api.util.AssertUtil;

public class RundeckMonitorClient extends RundeckClient{

	private static final long serialVersionUID = 6744841390473909439L;

	public RundeckMonitorClient(String url, String login, String password)
			throws IllegalArgumentException {
		super(url, login, password);
	}

	@Override
	public RundeckHistory getHistory( final String project, final String statut, final Long max, final Long offset) throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {

		AssertUtil.notBlank(project, "project is mandatory to get the history !"); //$NON-NLS-1$

		return new ApiCall(this).get( new ApiPathBuilder( "/history" ).param( "project", project).param( "statFilter", statut ).param( "max", max ).param("offset", offset), new HistoryParser( "/events" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
	}
}

Fix MonitorClient not working to detect failed jobs


package refinedstorage.api.autocrafting.registry;

import javax.annotation.Nullable;

/**
 * A registry that stores crafting task factories.
 * Implement this for adding custom crafting tasks.
 */
public interface ICraftingTaskRegistry {
    /**
     * Adds a crafting task factory to the registry.
     * The id is used for identifying tasks when they are read from disk.
     *
     * @param id      the id of the factory
     * @param factory the factory
     */
    void addFactory(String id, ICraftingTaskFactory factory);

    /**
     * Returns the crafting task factory by factory id.
     *
     * @param id the factory id
     * @return the factory
     */
    @Nullable
    ICraftingTaskFactory getFactory(String id);
}

package refinedstorage.api.autocrafting.registry;

import javax.annotation.Nullable;

/**
 * A registry that stores crafting task factories.
 * Implement this to handle the loading of custom crafting tasks.
 */
public interface ICraftingTaskRegistry {
    /**
     * Adds a crafting task factory to the registry.
     * The id is used for identifying tasks when they are read from disk.
     *
     * @param id      the id of the factory
     * @param factory the factory
     */
    void addFactory(String id, ICraftingTaskFactory factory);

    /**
     * Returns the crafting task factory by factory id.
     *
     * @param id the factory id
     * @return the factory
     */
    @Nullable
    ICraftingTaskFactory getFactory(String id);
}

Update some docs, 1.0.1 done

Update some docs, 1.0.1 done


package com.salesforce.phoenix.schema;

public enum ColumnSortOrder {

	ASC, DESC;

	public static ColumnSortOrder defaultValue() {
		return ASC;
	}

	public static ColumnSortOrder fromDDLStatement(String sortOrder) {
		return sortOrder == null ? defaultValue() : ColumnSortOrder.valueOf(sortOrder.toUpperCase());
	}

	public static ColumnSortOrder fromDbValue(int value) {
		switch (value) {
		    case 0: return ASC;
		    case 1: return DESC;
		    default: throw new IllegalArgumentException("Bad db value for ColumnSortOrder: " + value);
		}
	}

	public int toDbValue() {
		return this == ASC ? 0 : 1;
	}
}

package com.salesforce.phoenix.schema;

public enum ColumnSortOrder {

	ASC, DESC;

	public static ColumnSortOrder defaultValue() {
		return ASC;
	}

	public static ColumnSortOrder fromDDLStatement(String sortOrder) {
		return sortOrder == null ? defaultValue() : ColumnSortOrder.valueOf(sortOrder.toUpperCase());
	}

	public static ColumnSortOrder fromDbValue(int value) {
		switch (value) {
		    case 0: return ASC;
		    case 1: return DESC;
		    default: return defaultValue();
		}
	}

	public int toDbValue() {
		return this == ASC ? 0 : 1;
	}
}

Return default value when sort order is not found in system.table.


package arnelid.bjorn.redo.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import arnelid.bjorn.redo.model.Family;
import arnelid.bjorn.redo.repository.FamilyRepository;

@RestController
public class FamilyController {
	@Autowired
	FamilyRepository familyRepository;

	@GetMapping("/{name}")
	Family getFamily(@PathVariable String name) {
		return familyRepository.findByName(name);
	}

	@PostMapping(path = "/Family", consumes = MediaType.APPLICATION_JSON_VALUE)
	void postFamily(@RequestBody Family newFamily) {
		familyRepository.save(newFamily);
	}
}

package arnelid.bjorn.redo.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import arnelid.bjorn.redo.model.Family;
import arnelid.bjorn.redo.repository.FamilyRepository;

@RestController
public class FamilyController {
	@Autowired
	FamilyRepository familyRepository;

	@PostMapping(path = "/family", consumes = MediaType.APPLICATION_JSON_VALUE)
	void postFamily(@RequestBody Family newFamily) {
		familyRepository.save(newFamily);
	}

	@DeleteMapping("/{name}")
	void deleteFAmily(@PathVariable String name) {
		Family toBeDeleted = familyRepository.findByName(name);
		familyRepository.delete(toBeDeleted);
	}

	@GetMapping("/{name}")
	Family getFamily(@PathVariable String name) {
		return familyRepository.findByName(name);
	}
}

Add delete mapping for family.

Add delete mapping for family.


package com.darwinsys.springbootdemo;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller()
public class NotAServlet {

	@RequestMapping(value="/notaservlet", method=RequestMethod.GET)
	public String doWork(@RequestParam("name") String name, ModelMap model) {
		System.out.println("NotAServlet.doWork()");
		model.addAttribute("greetings", String.format("<b>Hello %s!!</b>", name));
		return "hello";
	}
}

package com.darwinsys.springbootdemo;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * It's not a Servlet, it's a Controller
 */
@Controller()
public class NotAServlet {

	@RequestMapping(value="/notaservlet", method=RequestMethod.GET)
	public String doWork(@RequestParam("name") String name, ModelMap model) {
		System.out.println("NotAServlet.doWork()");
		model.addAttribute("greetings", String.format("<b>Hello %s!!</b>", name));
		return "hello";
	}
}

Add doc comment for cryptic name.

Add doc comment for cryptic name.


package edu.virginia.psyc.r01.persistence;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.collections.map.HashedMap;
import org.mindtrails.domain.questionnaire.LinkedQuestionnaireData;
import org.mindtrails.domain.questionnaire.MeasureField;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import java.util.Collections;
import java.util.Map;

/**
 * Created by samportnow on 7/21/14.
 */
@Entity
@Table(name="CC")
@EqualsAndHashCode(callSuper = true)
@Data

public class CC extends LinkedQuestionnaireData {

    @MeasureField(desc="While reading the brief stories in the training program, how much did you relate to the situations presented?")
    @NotNull
    private Integer related;

    @MeasureField(desc="While reading the brief stories in the training program, how much did you feel like it could be you behaving that way in those stories?")
    @NotNull
    private Integer compare;

    @Override
    public Map<Integer, String> getScale(String scale) {
        Map<Integer, String> tmpScale = new HashedMap();
        tmpScale.put(1, "Not at all");
        tmpScale.put(2, "Slightly");
        tmpScale.put(3, "Somewhat");
        tmpScale.put(4, "Mostly");
        tmpScale.put(5, "Very much");
        return Collections.unmodifiableMap(tmpScale);
    }
}

package edu.virginia.psyc.r01.persistence;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.collections.map.HashedMap;
import org.mindtrails.domain.questionnaire.LinkedQuestionnaireData;
import org.mindtrails.domain.questionnaire.MeasureField;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;

/**
 * Created by samportnow on 7/21/14.
 */
@Entity
@Table(name="CC")
@EqualsAndHashCode(callSuper = true)
@Data

public class CC extends LinkedQuestionnaireData {

    @MeasureField(desc="While reading the brief stories in the training program, how much did you relate to the situations presented?")
    @NotNull
    private Integer related;

    @MeasureField(desc="While reading the brief stories in the training program, how much did you feel like it could be you behaving that way in those stories?")
    @NotNull
    private Integer compare;

    @Override
    public Map<Integer, String> getScale(String scale) {
        Map<Integer, String> tmpScale = new TreeMap<>();
        tmpScale.put(1, "Not at all");
        tmpScale.put(2, "Slightly");
        tmpScale.put(3, "Somewhat");
        tmpScale.put(4, "Mostly");
        tmpScale.put(5, "Very much");
        return Collections.unmodifiableMap(tmpScale);
    }
}

Return the scale in the order it was created.


/*
 * Copyright (c) 2013 TIBCO Software Inc. All Rights Reserved.
 *
 * Use is subject to the terms of the TIBCO license terms accompanying the download of this code.
 * In most instances, the license terms are contained in a file named license.txt.
 */
package org.fabrician.enabler.hadoop;

public class HadoopTasktrackerMBeanServerRef extends HadoopMBeanServerRef {

    public String getEnableFlagVar() {
        return "hadoop_enabler_ENABLE_DATANODE";
    }

    public String getJMXBasePortVar() {
        return "hadoop_enabler_DATANODE_JMX_BASEPORT";
    }

}

/*
 * Copyright (c) 2013 TIBCO Software Inc. All Rights Reserved.
 *
 * Use is subject to the terms of the TIBCO license terms accompanying the download of this code.
 * In most instances, the license terms are contained in a file named license.txt.
 */
package org.fabrician.enabler.hadoop;

public class HadoopTasktrackerMBeanServerRef extends HadoopMBeanServerRef {

    public String getEnableFlagVar() {
        return "hadoop_enabler_ENABLE_TASKTRACKER";
    }

    public String getJMXBasePortVar() {
        return "hadoop_enabler_TASKTRACKER_JMX_BASEPORT";
    }

}

Fix name of enabler flag variable for tasktracker.


package org.enoir.graphvizapi.test;
import org.enoir.graphvizapi.Attribute;
import org.enoir.graphvizapi.Node;
import org.enoir.graphvizapi.exception.AttributeNotFondException;
import org.junit.Assert;
import org.junit.Test;

/**
 * Created by frank on 2014/11/27.
 */
public class TestException {
    @Test
    public void TestAttributeNotFond(){
        try {
            Node node = new Node("testId");
            node.addAttribute(new Attribute("color", "#000"));
            node.removeAttribute("label");
        }catch (AttributeNotFondException e) {
            Assert.assertTrue(true);
        }catch (Exception ex){
            Assert.assertTrue(false);
        }
    }
}

package org.enoir.graphvizapi.test;
import org.enoir.graphvizapi.*;
import org.enoir.graphvizapi.exception.AttributeNotFondException;
import org.enoir.graphvizapi.exception.GraphException;
import org.junit.Assert;
import org.junit.Test;

/**
 * Created by frank on 2014/11/27.
 */
public class TestException {
    @Test
    public void TestAttributeNotFond(){
        try {
            Node node = new Node("testId");
            node.addAttribute(new Attribute("color", "#000"));
            node.removeAttribute("label");
        }catch (AttributeNotFondException e) {
            Assert.assertTrue(true);
        }catch (Exception ex){
            Assert.assertTrue(false);
        }
    }

    @Test
    public void TestDotCommandNotFound() {
        Graphviz gz = new Graphviz("/usr/bin/dot1","./");
        Graph graph = new Graph("g1", GraphType.DIGRAPH);
        String type = "png";
        try {
            byte[] bytearray = gz.getGraphByteArray(graph, type, "100");
            Assert.assertTrue(false);
        }catch (GraphException ge){
            Assert.assertTrue(true);
        }
    }

}

Add dot command not found exception.

Add dot command not found exception.


/*
 * Copyright 2013 MovingBlocks
 *
 * 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.terasology.world.propagation;

/**
 */
public enum PropagationComparison {
    /**
     * Lighting is restricted in some way it wasn't before
     */
    MORE_RESTRICTED(true, false),
    /**
     * Lighting is identical to before
     */
    IDENTICAL(false, false),
    /**
     * Lighting is strictly more permissive than before
     */
    MORE_PERMISSIVE(false, true);

    private boolean restricting;
    private boolean permitting;

     PropagationComparison(boolean restricts, boolean permits) {
        this.restricting = restricts;
        this.permitting = permits;
    }

    public boolean isRestricting() {
        return restricting;
    }

    public boolean isPermitting() {
        return permitting;
    }
}

/*
 * Copyright 2013 MovingBlocks
 *
 * 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.terasology.world.propagation;

/**
 * An enum that describes how propagation rules have changes when blocks are replaced with others
 */
public enum PropagationComparison {
    /**
     * Propagation is restricted in some way it wasn't before
     */
    MORE_RESTRICTED(true, false),
    /**
     * Propagation is identical to before
     */
    IDENTICAL(false, false),
    /**
     * Propagation is strictly more permissive than before
     */
    MORE_PERMISSIVE(false, true);

    private boolean restricting;
    private boolean permitting;

     PropagationComparison(boolean restricts, boolean permits) {
        this.restricting = restricts;
        this.permitting = permits;
    }

    public boolean isRestricting() {
        return restricting;
    }

    public boolean isPermitting() {
        return permitting;
    }
}

Update javadoc for propgation comparison enum


package org.basex.server;

import org.basex.util.*;
import org.basex.util.hash.*;

/**
 * This class delays blocked clients.
 *
 * @author BaseX Team 2005-18, BSD License
 * @author Christian Gruen
 */
public final class ClientBlocker {
  /** Temporarily blocked clients. */
  private final TokenIntMap blocked = new TokenIntMap();

  /**
   * Registers the client and delays the process.
   * @param client client address
   */
  public synchronized void delay(final byte[] client) {
    int delay = blocked.get(client);
    delay = delay == -1 ? 1 : Math.min(delay, 1024) << 1;
    blocked.put(client, delay);
    while(--delay > 0) Performance.sleep(1000);
  }

  /**
   * Resets the login delay after successful login.
   * @param client client address
   */
  public synchronized void remove(final byte[] client) {
    blocked.remove(client);
  }
}

package org.basex.server;

import org.basex.util.*;
import org.basex.util.hash.*;

/**
 * This class delays blocked clients.
 *
 * @author BaseX Team 2005-18, BSD License
 * @author Christian Gruen
 */
public final class ClientBlocker {
  /** Temporarily blocked clients. */
  private final TokenIntMap blocked = new TokenIntMap();

  /**
   * Registers the client and delays the process.
   * @param client client address
   */
  public synchronized void delay(final byte[] client) {
    int delay = blocked.get(client);
    delay = delay == -1 ? 1 : Math.min(delay, 1024) << 1;
    blocked.put(client, delay);
    while(--delay > 0) Performance.sleep(100);
  }

  /**
   * Resets the login delay after successful login.
   * @param client client address
   */
  public synchronized void remove(final byte[] client) {
    blocked.remove(client);
  }
}

Reduce delays for invalid passwords

[MOD] Server: Reduce delays for invalid passwords


package com.gh4a.loader;

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

import org.eclipse.egit.github.core.User;
import org.eclipse.egit.github.core.service.OrganizationService;

import android.content.Context;

import com.gh4a.Gh4Application;

public class OrganizationListLoader extends BaseLoader<List<User>> {
    private String mUserLogin;

    public OrganizationListLoader(Context context, String userLogin) {
        super(context);
        mUserLogin = userLogin;
    }

    @Override
    public List<User> doLoadInBackground() throws IOException {
        OrganizationService orgService = (OrganizationService)
                Gh4Application.get().getService(Gh4Application.ORG_SERVICE);
        return orgService.getOrganizations(mUserLogin);
    }
}

package com.gh4a.loader;

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

import org.eclipse.egit.github.core.User;
import org.eclipse.egit.github.core.service.OrganizationService;

import android.content.Context;

import com.gh4a.Gh4Application;

public class OrganizationListLoader extends BaseLoader<List<User>> {
    private String mUserLogin;

    public OrganizationListLoader(Context context, String userLogin) {
        super(context);
        mUserLogin = userLogin;
    }

    @Override
    public List<User> doLoadInBackground() throws IOException {
        Gh4Application app = Gh4Application.get();
        OrganizationService orgService = (OrganizationService)
                app.getService(Gh4Application.ORG_SERVICE);
        if (mUserLogin.equals(app.getAuthLogin())) {
            return orgService.getOrganizations();
        } else {
            return orgService.getOrganizations(mUserLogin);
        }
    }
}

Include private organization memberships for logged in user.

Closes #256.


/*
 * Bach - Java Shell Builder
 * Copyright (C) 2019 Christian Stein
 *
 * 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
 *
 *     https://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.
 */

module de.sormuras.bach {
  requires java.compiler;
  requires java.net.http;

  exports de.sormuras.bach;
  exports de.sormuras.bach.project;

  uses java.util.spi.ToolProvider;
}

/*
 * Bach - Java Shell Builder
 * Copyright (C) 2019 Christian Stein
 *
 * 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
 *
 *     https://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.
 */

// --main-class de.sormuras.bach.Bach
module de.sormuras.bach {
  requires java.compiler;
  requires java.net.http;

  exports de.sormuras.bach;
  exports de.sormuras.bach.project;

  uses java.util.spi.ToolProvider;
}

Add textual main class "declaration"

Add textual main class "declaration"


package uk.ac.ebi.quickgo.rest.search.query;

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

/**
 * Holds the data required to specify a filter value
 *
 * @author Tony Wardell
 * Date: 03/05/2016
 * Time: 10:25
 * Created with IntelliJ IDEA.
 */
public class PrototypeFilter {

    private static final String COMMA = ",";
    private String filterField;
    private List<String> args;
    private Validator<String> validator;

    public String getFilterField() {
        return filterField;
    }

    public List<String> getArgs() {
        return args;
    }

    public static final PrototypeFilter create(String filterField, String argIncludingDelimiters, Validator<String>
            validator ){
        PrototypeFilter prototypeFilter = new PrototypeFilter();
        prototypeFilter.filterField = filterField;
        prototypeFilter.args = Arrays.asList(argIncludingDelimiters.split(COMMA));
        prototypeFilter.validator = validator;
        return prototypeFilter;
    }

    /**
     *
     * Test each argument in the list to see if its valid
     */
    public void validate(){
        args.stream().forEach(a -> validator.validate(a));
    }
}

package uk.ac.ebi.quickgo.rest.search.query;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

/**
 * Holds the data required to specify a filter value
 *
 * @author Tony Wardell
 * Date: 03/05/2016
 * Time: 10:25
 * Created with IntelliJ IDEA.
 */
public class PrototypeFilter {

    private static final String COMMA = ",";
    private String filterField;
    private List<String> args;
    private Validator<String> validator;

    public String getFilterField() {
        return filterField;
    }

    public static final PrototypeFilter create(String filterField, String argIncludingDelimiters, Validator<String>
            validator ){
        PrototypeFilter prototypeFilter = new PrototypeFilter();
        prototypeFilter.filterField = filterField;
        prototypeFilter.args = Arrays.asList(argIncludingDelimiters.split(COMMA));
        prototypeFilter.validator = validator;
        return prototypeFilter;
    }

    /**
     *
     * Test each argument in the list to see if its valid
     */
    public void validate(){
        args.stream().forEach(a -> validator.validate(a));
    }

    public Stream<String> provideStream(){
        return args.stream();

    }
}

Stop direct access to the list of args, allow them to be streamed instead.


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

package org.cloudfoundry.client;

import org.junit.Test;

import static org.cloudfoundry.client.ValidationResult.Status.VALID;
import static org.junit.Assert.assertEquals;

public final class ValidationResultTest {

    @Test
    public void invalid() {
        ValidationResult result = ValidationResult.builder()
                .message("Test Message")
                .build();

        assertEquals(VALID, result.getStatus());
    }

    @Test
    public void valid() {
        ValidationResult result = ValidationResult.builder()
                .build();

        assertEquals(VALID, result.getStatus());
    }

}

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

package org.cloudfoundry.client;

import org.junit.Test;

import static org.cloudfoundry.client.ValidationResult.Status.INVALID;
import static org.cloudfoundry.client.ValidationResult.Status.VALID;
import static org.junit.Assert.assertEquals;

public final class ValidationResultTest {

    @Test
    public void invalid() {
        ValidationResult result = ValidationResult.builder()
                .message("Test Message")
                .build();

        assertEquals(INVALID, result.getStatus());
    }

    @Test
    public void valid() {
        ValidationResult result = ValidationResult.builder()
                .build();

        assertEquals(VALID, result.getStatus());
    }

}

Revert "Unit Test Failure Trial"

Revert "Unit Test Failure Trial"

This reverts commit 7e2b425fffcb54ab68e1a462c64305fd269f7d3f.


package edu.northwestern.bioinformatics.studycalendar.domain.auditing;

import java.util.Date;

/**
 * Subclass of core-commons' DataAuditInfo that aliases the "on" property as "time".
 * This is so that it can be used in HQL queries ("on" is apparently a reserved word).
 *
 * @author Rhett Sutphin
 */
public class DataAuditInfo extends edu.nwu.bioinformatics.commons.DataAuditInfo {
    public DataAuditInfo() { }

    public DataAuditInfo(String by, String ip) {
        super(by, ip);
    }

    public DataAuditInfo(String by, String ip, Date on) {
        super(by, ip, on);
    }

    public static DataAuditInfo copy(edu.nwu.bioinformatics.commons.DataAuditInfo source) {
        return new DataAuditInfo(
            source.getBy(), source.getIp(), source.getOn()
        );
    }

    public Date getTime() {
        return getOn();
    }

    public void setTime(Date on) {
        setOn(on);
    }

    /* Have to duplicate other accessors so that it will work with annotations without
       annotating the superclass. */
    public String getUsername() { return super.getBy(); }
    public void setUsername(String by) { super.setBy(by); }
    public String getIp() { return super.getIp(); }
    public void setIp(String ip) { super.setIp(ip); }
}

package edu.northwestern.bioinformatics.studycalendar.domain.auditing;

import org.hibernate.annotations.Type;

import java.util.Date;
import java.sql.Timestamp;

/**
 * Subclass of core-commons' DataAuditInfo that aliases the "on" property as "time".
 * This is so that it can be used in HQL queries ("on" is apparently a reserved word).
 *
 * @author Rhett Sutphin
 */
public class DataAuditInfo extends edu.nwu.bioinformatics.commons.DataAuditInfo {
    public DataAuditInfo() { }

    public DataAuditInfo(String by, String ip) {
        super(by, ip);
    }

    public DataAuditInfo(String by, String ip, Date on) {
        super(by, ip, on);
    }

    public static DataAuditInfo copy(edu.nwu.bioinformatics.commons.DataAuditInfo source) {
        return new DataAuditInfo(
            source.getBy(), source.getIp(), source.getOn()
        );
    }

    @Type(type = "timestamp")
    public Date getTime() {
        return getOn();
    }

    public void setTime(Date on) {
        setOn(on);
    }

    /* Have to duplicate other accessors so that it will work with annotations without
       annotating the superclass. */
    public String getUsername() { return super.getBy(); }
    public void setUsername(String by) { super.setBy(by); }
    public String getIp() { return super.getIp(); }
    public void setIp(String ip) { super.setIp(ip); }
}

Add timestamp type to time property for oracle


package devopsdistilled.operp.server.data.repo.stock;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import devopsdistilled.operp.server.data.entity.stock.Stock;

@Repository
public interface StockRepository extends JpaRepository<Stock, Long> {

}

package devopsdistilled.operp.server.data.repo.stock;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import devopsdistilled.operp.server.data.entity.items.Item;
import devopsdistilled.operp.server.data.entity.stock.Stock;
import devopsdistilled.operp.server.data.entity.stock.Warehouse;

@Repository
public interface StockRepository extends JpaRepository<Stock, Long> {
	Stock findByItemAndWarehouse(Item item,Warehouse warehouse);

}

Create functionalities to find stock with item and warehouse


package org.chaplib;

import static org.junit.Assert.*;

import org.apache.http.HttpRequest;
import org.apache.http.client.methods.HttpGet;
import org.junit.Before;
import org.junit.Test;

public class TestDefaultUserAgentGenerator {

    private DefaultUserAgentGenerator impl;

    @Before
    public void setUp() {
        impl = new DefaultUserAgentGenerator();
    }

    @Test
    public void generatesAUserAgentString() {
        HttpRequest request = new HttpGet("http://www.example.com/");
        impl.setUserAgent(request);
        assertFalse("".equals(request.getFirstHeader("User-Agent").getValue().trim()));
    }
}

package org.chaplib;

import static org.junit.Assert.*;

import org.apache.http.HttpRequest;
import org.apache.http.client.methods.HttpGet;
import org.junit.Before;
import org.junit.Test;

public class TestDefaultUserAgentGenerator {

    private DefaultUserAgentGenerator impl;

    @Before
    public void setUp() {
        impl = new DefaultUserAgentGenerator();
    }

    /*
     * "User agents SHOULD include this [User-Agent] field with requests."
     * http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
     */
    @Test
    public void generatesAUserAgentString() {
        HttpRequest request = new HttpGet("http://www.example.com/");
        impl.setUserAgent(request);
        assertFalse("".equals(request.getFirstHeader("User-Agent").getValue().trim()));
    }
}

Include RFC2616 quote on unit test for User-Agent.


package uk.co.sftrabbit.stackanswers;

import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import uk.co.sftrabbit.stackanswers.app.DrawerActivity;

public class AuthenticationActivity extends DrawerActivity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_authentication);

		setDrawerIndicatorEnabled(false);

		WebView webView = (WebView) findViewById(R.id.authentication_web_view);
		webView.setWebViewClient(new WebViewClient());

		WebSettings webSettings = webView.getSettings();
		webSettings.setJavaScriptEnabled(true);

		webView.loadUrl(
			"https://stackexchange.com/oauth/dialog?" +
			"client_id=2265&" +
			"scope=read_inbox,write_access,private_info&" +
			"redirect_uri=https://stackexchange.com/oauth/login_success"
		);
	}
}

package uk.co.sftrabbit.stackanswers;

import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import uk.co.sftrabbit.stackanswers.app.DrawerActivity;

public class AuthenticationActivity extends DrawerActivity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_authentication);

		setDrawerIndicatorEnabled(false);

		final ProgressBar progressBar =
			(ProgressBar) findViewById(R.id.authentication_progress);

		WebView webView = (WebView) findViewById(R.id.authentication_web_view);
		webView.setWebViewClient(new WebViewClient());
		webView.setWebChromeClient(new WebChromeClient() {
			@Override
			public void onProgressChanged(WebView webview, int newProgress) {
				progressBar.setProgress(newProgress);
			}
		});

		WebSettings webSettings = webView.getSettings();
		webSettings.setJavaScriptEnabled(true);

		webView.loadUrl(
			"https://stackexchange.com/oauth/dialog?" +
			"client_id=2265&" +
			"scope=read_inbox,write_access,private_info&" +
			"redirect_uri=https://stackexchange.com/oauth/login_success"
		);
	}
}

Update progress bar as authentication pages load


package net.openhft.chronicle.bytes;

import net.openhft.chronicle.core.Maths;
import org.junit.Test;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.Random;

import static junit.framework.TestCase.assertEquals;

public class StopBitDecimalTest {
    @Test
    public void testDecimals() {
        Bytes<ByteBuffer> bytes = Bytes.elasticHeapByteBuffer(16);
        Random rand = new Random();
        for (int i = 0; i < 10000; i++) {
            rand.setSeed(i);
            bytes.clear();
            int scale = rand.nextInt(10);
            double d = (rand.nextLong() % 1e14) / Maths.tens(scale);
            bytes.writeStopBitDecimal(d);
            BigDecimal bd = BigDecimal.valueOf(d);
            long v = bytes.readStopBit();
            BigDecimal ebd = new BigDecimal(BigInteger.valueOf(v / 10), (int) (Math.abs(v) % 10));
            assertEquals("i: " + i + ", d: " + d + ", v: " + v, ebd.doubleValue(), bd.doubleValue(), 0.0);
            bytes.readPosition(0);
            double d2 = bytes.readStopBitDecimal();
            assertEquals("i: " + i + ", d: " + d + ", v: " + v, d, d2, 0.0);
        }

    }
}

package net.openhft.chronicle.bytes;

import net.openhft.chronicle.core.Maths;
import org.junit.Test;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.Random;

import static junit.framework.TestCase.assertEquals;

public class StopBitDecimalTest {
    @Test
    public void testDecimals() {
        Bytes<ByteBuffer> bytes = Bytes.elasticHeapByteBuffer(16);
        Random rand = new Random();
        for (int i = 0; i < 10_000; i++) {
            rand.setSeed(i);
            bytes.clear();
            int scale = rand.nextInt(10);
            double d = (rand.nextLong() % 1e14) / Maths.tens(scale);
            bytes.writeStopBitDecimal(d);
            BigDecimal bd = BigDecimal.valueOf(d);
            long v = bytes.readStopBit();
            BigDecimal ebd = new BigDecimal(BigInteger.valueOf(v / 10), (int) (Math.abs(v) % 10));
            assertEquals("i: " + i + ", d: " + d + ", v: " + v, ebd.doubleValue(), bd.doubleValue(), 0.0);
            bytes.readPosition(0);
            double d2 = bytes.readStopBitDecimal();
            assertEquals("i: " + i + ", d: " + d + ", v: " + v, d, d2, 0.0);
        }

    }
}

Add support for stopBit encoded small decimal.


package edu.rpi.cs.yacs.core;

import android.app.Application;

import com.crashlytics.android.Crashlytics;
import com.squareup.leakcanary.LeakCanary;

import edu.rpi.cs.yacs.retrofit.ServiceHelper;
import io.fabric.sdk.android.Fabric;
import io.realm.Realm;
import io.realm.RealmConfiguration;

/**
 * Created by Mark Robinson on 10/4/16.
 */
public class YACSApplication extends Application {
    private static YACSApplication instance;

    private ServiceHelper serviceHelper = null;
    private Realm realm = null;

    public static YACSApplication getInstance() {
        return instance;
    }

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

        if (LeakCanary.isInAnalyzerProcess(this)) {
            // This process is dedicated to LeakCanary for heap analysis.
            return;
        }

        Fabric.with(this, new Crashlytics());

        instance = this;

        LeakCanary.install(this);

        serviceHelper = new ServiceHelper(getApplicationContext());

        RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(this).build();
        Realm.setDefaultConfiguration(realmConfiguration);

        realm = Realm.getDefaultInstance();
    }

    public ServiceHelper getServiceHelper() {
        return serviceHelper;
    }

    public Realm getRealm() {
        return realm;
    }
}

package edu.rpi.cs.yacs.core;

import android.app.Application;

import com.crashlytics.android.Crashlytics;
import com.squareup.leakcanary.LeakCanary;

import edu.rpi.cs.yacs.enums.RecyclerViewMode;
import edu.rpi.cs.yacs.retrofit.ServiceHelper;
import io.fabric.sdk.android.Fabric;
import io.realm.Realm;
import io.realm.RealmConfiguration;

/**
 * Created by Mark Robinson on 10/4/16.
 */
public class YACSApplication extends Application {
    private static YACSApplication instance;

    private ServiceHelper serviceHelper = null;
    private Realm realm = null;
    private RecyclerViewMode recyclerViewMode = RecyclerViewMode.DEPARTMENTS;

    public static YACSApplication getInstance() {
        return instance;
    }

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

        if (LeakCanary.isInAnalyzerProcess(this)) {
            // This process is dedicated to LeakCanary for heap analysis.
            return;
        }

        Fabric.with(this, new Crashlytics());

        instance = this;

        LeakCanary.install(this);

        serviceHelper = new ServiceHelper(getApplicationContext());

        RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(this).build();
        Realm.setDefaultConfiguration(realmConfiguration);

        realm = Realm.getDefaultInstance();
    }

    public ServiceHelper getServiceHelper() {
        return serviceHelper;
    }

    public Realm getRealm() {
        return realm;
    }

    public RecyclerViewMode getRecyclerViewMode() {
        return recyclerViewMode;
    }

    public void setRecyclerViewMode(RecyclerViewMode recyclerViewMode) {
        this.recyclerViewMode = recyclerViewMode;
    }
}

Create RecyclerView Getters And Setters

Create RecyclerView Getters And Setters


package org.wildfly.swarm.container.runtime;

import java.net.URL;
import java.util.List;

import junit.framework.Assert;
import org.jboss.dmr.ModelNode;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * @author Heiko Braun
 * @since 26/11/15
 */
public class ParserTestCase {

    private static URL xml;

    @BeforeClass
    public static void init() {
        ClassLoader cl = ParserTestCase.class.getClassLoader();
        xml = cl.getResource("standalone.xml");
    }

    @Test
    public void testDelegatingParser() throws Exception {
        StandaloneXmlParser parser = new StandaloneXmlParser();
        List<ModelNode> operations = parser.parse(xml);
        Assert.assertEquals(28, operations.size());
    }
}

package org.wildfly.swarm.container.runtime;

import java.net.URL;
import java.util.List;

import org.junit.Assert;
import org.jboss.dmr.ModelNode;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * @author Heiko Braun
 * @since 26/11/15
 */
public class ParserTestCase {

    private static URL xml;

    @BeforeClass
    public static void init() {
        ClassLoader cl = ParserTestCase.class.getClassLoader();
        xml = cl.getResource("standalone.xml");
    }

    @Test
    public void testDelegatingParser() throws Exception {
        StandaloneXmlParser parser = new StandaloneXmlParser();
        List<ModelNode> operations = parser.parse(xml);
        Assert.assertEquals(28, operations.size());
    }
}

Replace deprecated API usage with non-deprecated for junit.Assert.


package org.ligoj.app.resource.welcome;

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

import org.ligoj.app.api.FeaturePlugin;
import org.ligoj.app.iam.model.DelegateOrg;
import org.ligoj.app.model.DelegateNode;
import org.ligoj.bootstrap.model.system.SystemAuthorization;
import org.ligoj.bootstrap.model.system.SystemRole;
import org.ligoj.bootstrap.model.system.SystemRoleAssignment;
import org.ligoj.bootstrap.model.system.SystemUser;
import org.springframework.stereotype.Component;

/**
 * Initialize during the RBAC data on installation.
 */
@Component
public class InitializeRbacDataResource implements FeaturePlugin {

	@Override
	public String getKey() {
		return "feature:welcome:data-rbac";
	}

	@Override
	public List<Class<?>> getInstalledEntities() {
		return Arrays.asList(SystemUser.class, SystemRole.class, SystemAuthorization.class, SystemRoleAssignment.class, DelegateOrg.class,
				DelegateNode.class);
	}

}

package org.ligoj.app.resource.welcome;

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

import org.ligoj.app.api.FeaturePlugin;
import org.ligoj.app.iam.model.DelegateOrg;
import org.ligoj.app.model.DelegateNode;
import org.ligoj.bootstrap.model.system.SystemAuthorization;
import org.ligoj.bootstrap.model.system.SystemRole;
import org.ligoj.bootstrap.model.system.SystemRoleAssignment;
import org.ligoj.bootstrap.model.system.SystemUser;
import org.springframework.stereotype.Component;

/**
 * Initialize during the RBAC data on installation.
 */
@Component
public class InitializeRbacDataResource implements FeaturePlugin {

	@Override
	public String getKey() {
		return "feature:welcome:data-rbac";
	}

	@Override
	public List<Class<?>> getInstalledEntities() {
		return Arrays.asList(SystemUser.class, SystemRole.class, SystemAuthorization.class, SystemRoleAssignment.class, DelegateOrg.class,
				DelegateNode.class);
	}

	@Override
	public String getName() {
		return "Welcome Data RBAC";
	}

}

Add plug-in name for welcome RBAC

Add plug-in name for welcome RBAC


package com.intellij.jsp.impl;

import com.intellij.xml.XmlElementDescriptor;
import com.intellij.j2ee.j2eeDom.web.WebModuleProperties;
import com.intellij.psi.xml.XmlTag;

import javax.servlet.jsp.tagext.TagExtraInfo;

/**
 * Created by IntelliJ IDEA.
 * User: Maxim.Mossienko
 * Date: Mar 11, 2005
 * Time: 8:57:52 PM
 * To change this template use File | Settings | File Templates.
 */
public interface JspElementDescriptor extends XmlElementDescriptor {
  TagExtraInfo getExtraInfo(WebModuleProperties moduleProperties);
  boolean isRequiredAttributeImplicitlyPresent(XmlTag tag,String attributeName);
  XmlTag findVariableWithName(String name);
}

package com.intellij.jsp.impl;

import com.intellij.xml.XmlElementDescriptor;
import com.intellij.psi.xml.XmlTag;
import com.intellij.openapi.module.Module;

import javax.servlet.jsp.tagext.TagExtraInfo;

import org.jetbrains.annotations.Nullable;

/**
 * Created by IntelliJ IDEA.
 * User: Maxim.Mossienko
 * Date: Mar 11, 2005
 * Time: 8:57:52 PM
 * To change this template use File | Settings | File Templates.
 */
public interface JspElementDescriptor extends XmlElementDescriptor {
  TagExtraInfo getExtraInfo(@Nullable Module module);
  boolean isRequiredAttributeImplicitlyPresent(XmlTag tag,String attributeName);
  XmlTag findVariableWithName(String name);
}

Resolve of the implicit variables should also work in java modules (IDEADEV-3688)


/*
 * Copyright 2005 Joe Walker
 *
 * 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 uk.ltd.getahead.dwr;

/**
 * A very basic IoC container
 * @author Joe Walker [joe at getahead dot ltd dot uk]
 */
public interface Container
{
    /**
     * Get an instance of a bean of a given type.
     * @param id The type to get an instance of
     * @return The object of the given type
     */
    Object getBean(String id);
}

/*
 * Copyright 2005 Joe Walker
 *
 * 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 uk.ltd.getahead.dwr;

/**
 * A very basic IoC container
 * @author Joe Walker [joe at getahead dot ltd dot uk]
 */
public interface Container
{
    /**
     * Get an instance of a bean of a given type.
     * @param id The type to get an instance of
     * @return The object of the given type
     * @throws IllegalArgumentException If the given id does not refer to a bean
     */
    Object getBean(String id) throws IllegalArgumentException;
}

Make the interface clear when it comes to what happens when the container can't find the bean

git-svn-id: ba1d8d5a2a2c535e023d6080c1e5c29aa0f5364e@389 3a8262b2-faa5-11dc-8610-ff947880b6b2


package com.vsahin.moneycim;

import android.app.Activity;
import android.app.Application;

import com.vsahin.moneycim.Di.DaggerAppComponent;

import javax.inject.Inject;

import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;

/**
 * Created by Volkan Şahin on 17.08.2017.
 */

public class MoneycimApp extends Application implements HasActivityInjector {

    @Inject
    DispatchingAndroidInjector<Activity> dispatchingAndroidInjector;

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

        DaggerAppComponent
                .builder()
                .create(this)
                .inject(this);
    }

    @Override
    public AndroidInjector<Activity> activityInjector() {
        return dispatchingAndroidInjector;
    }
}

package com.vsahin.moneycim;

import android.app.Activity;
import android.app.Application;

import com.vsahin.moneycim.Di.DaggerAppComponent;

import javax.inject.Inject;

import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
import dagger.android.support.DaggerApplication;

/**
 * Created by Volkan Şahin on 17.08.2017.
 */

public class MoneycimApp extends DaggerApplication {
    @Override
    protected AndroidInjector<? extends DaggerApplication> applicationInjector() {
        return DaggerAppComponent.builder().create(this);
    }
}

Extend Application from DaggerApplication class


package replicant;

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

/**
 * Annotation use to mark code as incompatible with GWT.
 * The Name of the annotation is all that matters.
 */
@Retention( RetentionPolicy.CLASS )
@Target( { ElementType.TYPE, ElementType.METHOD } )
@Documented
@interface GwtIncompatible
{
}

package replicant;

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

/**
 * Annotation use to mark code as incompatible with GWT.
 * The Name of the annotation is all that matters.
 */
@Retention( RetentionPolicy.CLASS )
@Target( { ElementType.TYPE, ElementType.METHOD, ElementType.FIELD } )
@Documented
@interface GwtIncompatible
{
}

Make it possible to ignore fields

Make it possible to ignore fields


package leetcode;

/**
 * https://leetcode.com/problems/gas-station/
 */
public class Problem134 {
    public int canCompleteCircuit(int[] gas, int[] cost) {
        // TODO: to be implemented
        return 0;
    }
}

package leetcode;

/**
 * https://leetcode.com/problems/gas-station/
 */
public class Problem134 {
    public int canCompleteCircuit(int[] gas, int[] cost) {
        int totalGas = 0;
        int totalCost = 0;
        for (int g : gas) {
            totalGas += g;
        }
        for (int c : cost) {
            totalCost += c;
        }
        if (totalCost > totalGas) {
            return -1;
        }
        int[] diff = new int[gas.length];
        for (int i = 0; i < gas.length; i++) {
            int g = gas[i];
            int c = cost[i];
            int x = g - c;
            diff[i] = x;
        }
        int max = Integer.MIN_VALUE;
        int maxIdx = 0;
        for (int i = 0; i < diff.length; i++) {
            int sum = 0;
            for (int j = i; j < diff.length + i; j++) {
                int k = j;
                if (k >= diff.length) {
                    k = j - diff.length;
                }
                sum += diff[k];
                if (sum < 0) {
                    break;
                }
            }
            if (sum > max) {
                max = sum;
                maxIdx = i;
            }
        }
        return maxIdx;
    }

    public static void main(String[] args) {
        Problem134 prob = new Problem134();
        System.out.println(prob.canCompleteCircuit(
            new int[]{1, 2, 3, 3},
            new int[]{2, 1, 5, 1}));
        System.out.println(prob.canCompleteCircuit(
            new int[] {6, 1, 4, 3, 5},
            new int[] {3, 8, 2, 4,2}));
    }
}

Write something for problem 134 (it's still TLE)


package com.suse.salt.netapi.calls.modules;

import com.suse.salt.netapi.calls.LocalCall;

import com.google.gson.reflect.TypeToken;

import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * salt.modules.state
 */
public class State {

    private State() { }

    public static LocalCall<Map<String, Object>> apply(List<String> mods) {
        return apply(mods, Optional.empty(), Optional.empty());
    }

    public static LocalCall<Map<String, Object>> apply(String... mods) {
        return apply(Arrays.asList(mods), Optional.empty(), Optional.empty());
    }

    public static LocalCall<Map<String, Object>> apply(List<String> mods,
            Optional<Map<String, Object>> pillar, Optional<Boolean> queue) {
        Map<String, Object> kwargs = new LinkedHashMap<>();
        kwargs.put("mods", mods);
        if (pillar.isPresent()) {
            kwargs.put("pillar", pillar.get());
        }
        if (queue.isPresent()) {
            kwargs.put("queue", queue.get());
        }
        return new LocalCall<>("state.apply", Optional.empty(), Optional.of(kwargs),
                new TypeToken<Map<String, Object>>() { });
    }

    public static LocalCall<Object> showHighstate() {
        return new LocalCall<>("state.show_highstate", Optional.empty(), Optional.empty(),
                new TypeToken<Object>() { });
    }

}

package com.suse.salt.netapi.calls.modules;

import com.suse.salt.netapi.calls.LocalCall;

import com.google.gson.reflect.TypeToken;

import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * salt.modules.state
 */
public class State {

    private State() { }

    public static LocalCall<Map<String, Object>> apply(List<String> mods) {
        return apply(mods, Optional.empty(), Optional.empty());
    }

    public static LocalCall<Map<String, Object>> apply(String... mods) {
        return apply(Arrays.asList(mods), Optional.empty(), Optional.empty());
    }

    public static LocalCall<Map<String, Object>> apply(List<String> mods,
            Optional<Map<String, Object>> pillar, Optional<Boolean> queue) {
        Map<String, Object> kwargs = new LinkedHashMap<>();
        kwargs.put("mods", mods);
        pillar.ifPresent(p -> kwargs.put("pillar", p));
        queue.ifPresent(q -> kwargs.put("queue", q));
        return new LocalCall<>("state.apply", Optional.empty(), Optional.of(kwargs),
                new TypeToken<Map<String, Object>>() { });
    }

    public static LocalCall<Object> showHighstate() {
        return new LocalCall<>("state.show_highstate", Optional.empty(), Optional.empty(),
                new TypeToken<Object>() { });
    }

}

Use ifPresent() to avoid calling get()

Use ifPresent() to avoid calling get()


/**
 *
 */
package mathsquared.resultswizard2;

import javax.swing.table.TableModel;

/**
 * Represents data that can be edited in one or more stages and then transformed into another object.
 *
 * @author MathSquared
 * @param <T> the type of data that can be obtained from this model using {@link #getResult()}
 *
 */
public interface EditorTableModel<T> extends TableModel {
	/**
	 * Returns the number of stages used by this editor.
	 *
	 * @return a number indicating the number of stages; this number must always be greater than or equal to 1
	 */
	public int numStages ();

	/**
	 * Returns the current stage.
	 *
	 * @return a zero-based index for the current stage; this is guaranteed to be >= 0 and < {@link #numStages()}
	 */
	public int currentStage ();

	/**
	 * Moves to the next stage.
	 *
	 * @throws IllegalStateException if we are at the last stage
	 */
	public void nextStage ();

	/**
	 * Moves to the previous stage.
	 *
	 * @throws IllegalStateException if we are at the first stage
	 */
	public void previousStage ();

	/**
	 * Obtains the current result of this model. This only works if we are at the last stage.
	 *
	 * @return an object representing the data stored in this model
	 * @throws IllegalStateException if we are not at the last stage
	 */
	public T getResult ();
}

/**
 *
 */
package mathsquared.resultswizard2;

import javax.swing.table.TableModel;

/**
 * Represents data that can be edited in one or more stages and then transformed into another object.
 *
 *
Note that these stages should not change the column headers or layout in this table. They should only change which columns are editable and which are not. This will help generate a consistent user experience.

 *
 * @author MathSquared
 * @param <T> the type of data that can be obtained from this model using {@link #getResult()}
 *
 */
public interface EditorTableModel<T> extends TableModel {
	/**
	 * Returns the number of stages used by this editor.
	 *
	 * @return a number indicating the number of stages; this number must always be greater than or equal to 1
	 */
	public int numStages ();

	/**
	 * Returns the current stage.
	 *
	 * @return a zero-based index for the current stage; this is guaranteed to be >= 0 and < {@link #numStages()}
	 */
	public int currentStage ();

	/**
	 * Moves to the next stage.
	 *
	 * @throws IllegalStateException if we are at the last stage
	 */
	public void nextStage ();

	/**
	 * Moves to the previous stage.
	 *
	 * @throws IllegalStateException if we are at the first stage
	 */
	public void previousStage ();

	/**
	 * Obtains the current result of this model. This only works if we are at the last stage.
	 *
	 * @return an object representing the data stored in this model
	 * @throws IllegalStateException if we are not at the last stage
	 */
	public T getResult ();
}

ETM: Add doc note that stages shouldn't change column headers

The reason for the stage system is because of ERED. I'm planning on two
stages. The first allows the user to input event results. In preparing
for the second stage, the application generates sweepstakes points using
the event's specification. Then, in the second stage, these are exposed
to the user for editing.


/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.javascript.drivers;

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

import static java.lang.annotation.ElementType.TYPE;

/**
 * Intended to be used as an optional annotation for subclasses
 * of {@link org.mozilla.javascript.drivers.ScriptTestsBase}.
 * Sets the language version of test's script execution context.
 */
@Target(TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface LanguageVersion {
    int value();
}

Add copyright to new file.

Add copyright to new file.


package org.cryptonit;

import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;

public class CryptonitApplet extends Applet {
    protected CryptonitApplet(byte[] bArray, short bOffset, byte bLength) {
        register();
    }

    public static void install(byte[] bArray, short bOffset, byte bLength) {
        new CryptonitApplet(bArray, bOffset, bLength);
    }

    @Override
    public void process(APDU apdu) {
        byte buffer[] = apdu.getBuffer();
		if (apdu.isISOInterindustryCLA()) {
            if (buffer[ISO7816.OFFSET_INS] == (byte) (0xA4)) {
                return;
            }
            ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
        }
        ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
    }
}

package org.cryptonit;

import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.OwnerPIN;

public class CryptonitApplet extends Applet {
    private OwnerPIN pin;

    private final static byte PIN_MAX_LENGTH = 8;
    private final static byte PIN_MAX_TRIES  = 5;

    protected CryptonitApplet(byte[] bArray, short bOffset, byte bLength) {
        register();
    }

    public static void install(byte[] bArray, short bOffset, byte bLength) {
        new CryptonitApplet(bArray, bOffset, bLength);
    }

    @Override
    public void process(APDU apdu) {
        byte buffer[] = apdu.getBuffer();
		if (apdu.isISOInterindustryCLA()) {
            if (buffer[ISO7816.OFFSET_INS] == (byte) (0xA4)) {
                return;
            }
            ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
        }
        ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
    }
}

Add PIN variables and constants

Add PIN variables and constants


package de.innoaccel.wamp.server.message;

import java.util.List;

public class PublishMessage implements Message
{
    private String topicURI;

    private Object event;

    private boolean excludeMe;

    private List<String> exclude;

    private List<String> eligable;

    public PublishMessage(String topicURI, Object event)
    {
        this(topicURI, event, false);
    }

    public PublishMessage(String topicURI, Object event, boolean excludeMe)
    {
        this(topicURI, event, excludeMe, null, null);
    }

    public PublishMessage(String topicURI, Object event, List<String> exclude, List<String> eligable)
    {
        this(topicURI, event, false, exclude, eligable);
    }

    private PublishMessage(String topicURI, Object event, boolean excludeMe, List<String> exclude, List<String> eligable)
    {
        this.topicURI = topicURI;
        this.event = event;
        this.excludeMe = excludeMe;
        this.exclude = exclude;
        this.eligable = eligable;
    }

    @Override
    public int getMessageCode()
    {
        return Message.PUBLISH;
    }

    public String getTopicURI()
    {
        return this.topicURI;
    }

    public Object getEvent()
    {
        return event;
    }

    public boolean excludeMe()
    {
        return excludeMe;
    }

    public List<String> getExclude()
    {
        return exclude;
    }

    public List<String> getEligable()
    {
        return eligable;
    }
}

package de.innoaccel.wamp.server.message;

import java.util.List;

public class PublishMessage implements Message
{
    private String topicURI;

    private Object event;

    private boolean excludeMe;

    private List<String> exclude;

    private List<String> eligable;

    public PublishMessage(String topicURI, Object event)
    {
        this(topicURI, event, false);
    }

    public PublishMessage(String topicURI, Object event, boolean excludeMe)
    {
        this(topicURI, event, excludeMe, null, null);
    }

    public PublishMessage(String topicURI, Object event, List<String> exclude, List<String> eligable)
    {
        this(topicURI, event, false, exclude, eligable);
    }

    private PublishMessage(String topicURI, Object event, boolean excludeMe, List<String> exclude, List<String> eligable)
    {
        this.topicURI = topicURI;
        this.event = event;
        this.excludeMe = excludeMe;
        this.exclude = exclude;
        this.eligable = eligable;
    }

    @Override
    public int getMessageCode()
    {
        return Message.PUBLISH;
    }

    public String getTopicURI()
    {
        return this.topicURI;
    }

    public Object getEvent()
    {
        return event;
    }

    public boolean excludeMe()
    {
        return excludeMe;
    }

    public List<String> getExclude()
    {
        return exclude;
    }

    public List<String> getEligable()
    {
        return eligable;
    }

    public boolean isTargeted()
    {
        return (null != this.exclude || null != this.eligable);
    }
}

Add utility method to check between the two different publish message forms


package uk.co.uwcs.choob.support;

import java.io.*;
import org.mozilla.javascript.*;

public final class ObjectDBClassJSWrapper implements ObjectDBClass {
	private Function cls;

	public ObjectDBClassJSWrapper(Object obj) {
		if (!(obj instanceof Function)) {
			throw new RuntimeException("Trying to wrap a non-function type as a class!");
		}
		this.cls = (Function)obj;
	}

	public String getName() {
		Context cx = Context.enter();
		try {
			try {
				String ctorName = (String)JSUtils.getProperty((Scriptable)cls, "name");
				Scriptable scope = ((Scriptable)cls).getParentScope();

				// Get plugin name from scope (HACK)!
				String plugName = "<error>";
				while (scope != null) {
					try {
						plugName = (String)JSUtils.getProperty(scope, "__jsplugman_pluginName");
						scope = null;
					} catch (NoSuchFieldException e) {
						scope = scope.getParentScope();
					}
				}

				return "plugin." + plugName + "." + ctorName;
			} catch (NoSuchFieldException e) {
				// Do nothing.
			}
		} finally {
			cx.exit();
		}
		return "";
	}

	public Object newInstance() {
		Context cx = Context.enter();
		try {
			Scriptable scope = cls.getParentScope();
			return cls.construct(cx, scope, new Object[0]);
		} finally {
			cx.exit();
		}
	}
}

package uk.co.uwcs.choob.support;

import java.io.*;
import org.mozilla.javascript.*;

public final class ObjectDBClassJSWrapper implements ObjectDBClass {
	private Function cls;

	public ObjectDBClassJSWrapper(Object obj) {
		if (!(obj instanceof Function)) {
			throw new RuntimeException("Trying to wrap a non-function type as a class!");
		}
		this.cls = (Function)obj;
	}

	public String getName() {
		Context cx = Context.enter();
		try {
			try {
				String ctorName = (String)JSUtils.getProperty((Scriptable)cls, "name");
				Scriptable scope = ((Scriptable)cls).getParentScope();

				// Get plugin name from scope (HACK)!
				String plugName = "<error>";
				while (scope != null) {
					try {
						plugName = (String)JSUtils.getProperty(scope, "__jsplugman_pluginName");
						scope = null;
					} catch (NoSuchFieldException e) {
						scope = scope.getParentScope();
					}
				}

				return "plugins." + plugName + "." + ctorName;
			} catch (NoSuchFieldException e) {
				// Do nothing.
			}
		} finally {
			cx.exit();
		}
		return "";
	}

	public Object newInstance() {
		Context cx = Context.enter();
		try {
			Scriptable scope = cls.getParentScope();
			return cls.construct(cx, scope, new Object[0]);
		} finally {
			cx.exit();
		}
	}
}

Fix JS ObjectDB class wrapper to use format "plugins.Foo.Bar" not "plugin.Foo.Bar". Oops!


package hadoop;

import gsod.DataSet;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class MaxTemperatureMapper extends
		Mapper<LongWritable, Text, Text, IntWritable> {

	@Override
	public void map(LongWritable key, Text value,
			MaxTemperatureMapper.Context context) throws IOException,
			InterruptedException {
		String line = value.toString();

		if (line.startsWith("STN---"))
			return;

		String year = DataSet.getYear(line);
		int airTemperature = DataSet.getMax(line);

		if (airTemperature != DataSet.MISSING) {
			context.write(new Text(year), new IntWritable(airTemperature));
		}
	}

}

package hadoop;

import gsod.DataSet;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class MaxTemperatureMapper extends
		Mapper<LongWritable, Text, Text, IntWritable> {

	private String line;
	private String year;
	private int airTemperature;

	@Override
	public void map(LongWritable key, Text value,
			MaxTemperatureMapper.Context context) throws IOException,
			InterruptedException {
		line = value.toString();

		if (line.startsWith("STN---"))
			return;

		year = DataSet.getYear(line);
		airTemperature = DataSet.getMax(line);

		if (airTemperature != DataSet.MISSING) {
			context.write(new Text(year), new IntWritable(airTemperature));
		}
	}

}

Change yeat and temp to private class vars.


package eu.theunitry.fabula.launcher;

import javax.swing.*;
import java.awt.*;

public class UNLauncher extends JPanel
{

    private JLabel label;
    private JButton startBtn;

    public UNLauncher()
    {
        this.setBackground(new Color(255,82,44));
        this.setLayout(new BorderLayout());

        label = new JLabel("Fabula");
        label.setForeground(Color.white);
        label.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 40));
        label.setHorizontalAlignment(JLabel.CENTER);

        startBtn = new JButton("Start");
        startBtn.setPreferredSize(new Dimension(200,100));

        this.add(label, BorderLayout.CENTER);
        this.add(startBtn, BorderLayout.SOUTH);
    }

    public JPanel getPanel() {
        return this;
    }

}

package eu.theunitry.fabula.launcher;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;

public class UNLauncher extends JPanel
{

    private JLabel label;
    private JButton startBtn;

    public UNLauncher()
    {
        this.setBackground(new Color(255,82,44));
        this.setLayout(new BorderLayout());
        this.setBorder(new EmptyBorder(10, 10, 10, 10));

        label = new JLabel("Fabula");
        label.setForeground(Color.white);
        label.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 40));
        label.setHorizontalAlignment(JLabel.CENTER);

        startBtn = new JButton("Start");
        startBtn.setPreferredSize(new Dimension(200,100));

        /* Remove default styling */
        startBtn.setFocusPainted(false);
        startBtn.setBorderPainted(false);

        startBtn.setBackground(Color.white);
        startBtn.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20));
        startBtn.setForeground(Color.white);

        this.add(label, BorderLayout.CENTER);
        this.add(startBtn, BorderLayout.SOUTH);
    }

    public JPanel getPanel() {
        return this;
    }

}

Remove styling from start button

Remove styling from start button


package com.namelessdev.mpdroid.tools;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetworkHelper {

    public static final int MAX_RETRY = 5;

    public static boolean isNetworkConnected(Context context) {
        return isNetworkConnected(context, new int[0]);
    }

    public static Boolean isLocalNetworkConnected(Context context) {
        return isNetworkConnected(context, new int[]{ConnectivityManager.TYPE_WIFI, ConnectivityManager.TYPE_ETHERNET});
    }

    public static Boolean isNetworkConnected(Context context, int... allowedNetworkTypes) {

        for (int attempt = 0; attempt < MAX_RETRY; attempt++) {
            if (innerIsNetworkConnected(context, allowedNetworkTypes)) {
                return true;
            } else {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    //Nothing to do
                }
            }
        }
        return false;
    }

    public static Boolean innerIsNetworkConnected(Context context, int... allowedNetworkTypes) {

        NetworkInfo networkInfo;
        boolean networkConnected = false;
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);

        if (cm == null) {
            networkConnected = false;
        } else {
            networkInfo = cm.getActiveNetworkInfo();
            if (networkInfo == null) {
                networkConnected = false;
            } else if (!networkInfo.isAvailable() || !networkInfo.isConnected()) {
                networkConnected = false;
            } else if (allowedNetworkTypes.length == 0) {
                networkConnected = true;
            } else {
                for (int networkType = 0; networkType < allowedNetworkTypes.length && !networkConnected; networkType++) {
                    if (allowedNetworkTypes[networkType] == networkInfo.getType()) {
                        networkConnected = true;
                    }
                }
            }
        }
        return networkConnected;
    }
}

package com.namelessdev.mpdroid.tools;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetworkHelper {

	public static boolean isNetworkConnected(Context context) {
		ConnectivityManager cm = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		if (cm.getActiveNetworkInfo() == null)
			return false;
		return (cm.getActiveNetworkInfo().isAvailable() && cm
				.getActiveNetworkInfo().isConnected());
	}

	public static Boolean isLocalNetworkConnected(Context context) {
		ConnectivityManager cm = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		if (cm == null) {
			return false;
		}
		NetworkInfo netWorkinfo = cm.getActiveNetworkInfo();
		return (netWorkinfo != null
				&& (netWorkinfo.getType() == ConnectivityManager.TYPE_WIFI || netWorkinfo
						.getType() == ConnectivityManager.TYPE_ETHERNET) && netWorkinfo
					.isConnected());
	}
}

Revert "Improve robustness to temporary network problems."

Revert this since it does not seem to improve the lost connection management
and may have introduced a regression : see #345
This reverts commit ab94d7adb4798d3e8e0bbaeb8340e1580cf7f8a8.


package eu.rekawek.coffeegb.memory;

import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.SpeedMode;

public class Dma implements AddressSpace {

    private final AddressSpace addressSpace;

    private final AddressSpace oam;

    private final SpeedMode speedMode;

    private boolean transferInProgress;

    private boolean restarted;

    private int from;

    private int ticks;

    public Dma(AddressSpace addressSpace, AddressSpace oam, SpeedMode speedMode) {
        this.addressSpace = addressSpace;
        this.speedMode = speedMode;
        this.oam = oam;
    }

    @Override
    public boolean accepts(int address) {
        return address == 0xff46;
    }

    public void tick() {
        if (transferInProgress) {
            if (++ticks >= 648 / speedMode.getSpeedMode()) {
                transferInProgress = false;
                restarted = false;
                ticks = 0;
                for (int i = 0; i < 0xa0; i++) {
                    oam.setByte(0xfe00 + i, addressSpace.getByte(from + i));
                }
            }
        }
    }

    @Override
    public void setByte(int address, int value) {
        from = value * 0x100;
        restarted = isOamBlocked();
        ticks = 0;
        transferInProgress = true;
    }

    @Override
    public int getByte(int address) {
        return 0;
    }

    public boolean isOamBlocked() {
        return restarted || (transferInProgress && ticks >= 5);
    }
}

package eu.rekawek.coffeegb.memory;

import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.SpeedMode;

public class Dma implements AddressSpace {

    private final AddressSpace addressSpace;

    private final AddressSpace oam;

    private final SpeedMode speedMode;

    private boolean transferInProgress;

    private boolean restarted;

    private int from;

    private int ticks;

    private int regValue = 0xff;

    public Dma(AddressSpace addressSpace, AddressSpace oam, SpeedMode speedMode) {
        this.addressSpace = addressSpace;
        this.speedMode = speedMode;
        this.oam = oam;
    }

    @Override
    public boolean accepts(int address) {
        return address == 0xff46;
    }

    public void tick() {
        if (transferInProgress) {
            if (++ticks >= 648 / speedMode.getSpeedMode()) {
                transferInProgress = false;
                restarted = false;
                ticks = 0;
                for (int i = 0; i < 0xa0; i++) {
                    oam.setByte(0xfe00 + i, addressSpace.getByte(from + i));
                }
            }
        }
    }

    @Override
    public void setByte(int address, int value) {
        from = value * 0x100;
        restarted = isOamBlocked();
        ticks = 0;
        transferInProgress = true;
        regValue = value;
    }

    @Override
    public int getByte(int address) {
        return regValue;
    }

    public boolean isOamBlocked() {
        return restarted || (transferInProgress && ticks >= 5);
    }
}

Return the written value of DMA register.


package de.eightbitboy.ecorealms.control;

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

public class ControlActionMapping {

	enum Action {
		LMB,
		RMB
	}

	public interface ActionListener {
		void action(Action action);
	}

	private static final ControlActionMapping INSTANCE = new ControlActionMapping();

	private List<ActionListener> listeners = new ArrayList<ActionListener>();

	private ControlActionMapping() {
	}

	public static ControlActionMapping getInstance() {
		return INSTANCE;
	}

	public static void subscribe(ActionListener listener) {
		INSTANCE.listeners.add(listener);
	}

	public void fireAction(Action action) {
		for (ActionListener listener : listeners) {
			listener.action(action);
		}
	}
}

package de.eightbitboy.ecorealms.control;

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

public class ControlActionMapping {

	enum Action {
		LMB,
		RMB;

		public ActionInformation info() {
			return ControlActionMapping.getActionInformation();
		}
	}

	public class ActionInformation {

	}

	public interface ActionListener {
		void action(Action action);
	}

	private static final ControlActionMapping INSTANCE = new ControlActionMapping();

	private List<ActionListener> listeners = new ArrayList<ActionListener>();

	private ActionInformation actionInformation = new ActionInformation();

	private ControlActionMapping() {
	}

	public static ControlActionMapping getInstance() {
		return INSTANCE;
	}

	public static void subscribe(ActionListener listener) {
		INSTANCE.listeners.add(listener);
	}

	public static ActionInformation getActionInformation() {
		return INSTANCE.actionInformation;
	}

	public void fireAction(Action action) {
		for (ActionListener listener : listeners) {
			listener.action(action);
		}
	}
}

Prepare adding information to actions

Prepare adding information to actions


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

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Select;
import org.mybatis.dynamic.sql.select.render.SelectStatement;

public interface GroupByMapper {

    @Select({
        "${selectStatement}"
    })
    List<Map<String, Object>> generalSelect(SelectStatement selectStatement);
}

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

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.SelectProvider;
import org.mybatis.dynamic.sql.select.render.SelectStatement;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

public interface GroupByMapper {

    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    List<Map<String, Object>> generalSelect(SelectStatement selectStatement);
}

Update test to use new adapter

Update test to use new adapter


package it.near.sdk.Utils;

import android.content.Intent;

import it.near.sdk.Reactions.Content.Content;
import it.near.sdk.Reactions.Coupon.Coupon;
import it.near.sdk.Reactions.CustomJSON.CustomJSON;
import it.near.sdk.Reactions.Feedback.Feedback;
import it.near.sdk.Reactions.Poll.Poll;
import it.near.sdk.Reactions.SimpleNotification.SimpleNotification;

/**
 * Interface for being notified of core content types.
 *
 * @author cattaneostefano
 */
public interface CoreContentsListener {
    void getPollNotification(Intent intent, Poll notification, String recipeId);
    void getContentNotification(Intent intent, Content notification, String recipeId);
    void getCouponNotification(Intent intent, Coupon notification, String recipeId);
    void getCustomJSONNotification(Intent intent, CustomJSON notification, String recipeId);
    void getSimpleNotification(Intent intent, SimpleNotification s_notif, String recipeId);
    void getFeedbackNotification(Intent intent, Feedback s_notif, String recipeId);
}

package it.near.sdk.Utils;

import android.content.Intent;
import android.support.annotation.Nullable;

import it.near.sdk.Reactions.Content.Content;
import it.near.sdk.Reactions.Coupon.Coupon;
import it.near.sdk.Reactions.CustomJSON.CustomJSON;
import it.near.sdk.Reactions.Feedback.Feedback;
import it.near.sdk.Reactions.Poll.Poll;
import it.near.sdk.Reactions.SimpleNotification.SimpleNotification;

/**
 * Interface for being notified of core content types.
 *
 * @author cattaneostefano
 */
public interface CoreContentsListener {
    void getPollNotification(@Nullable Intent intent, Poll notification, String recipeId);
    void getContentNotification(@Nullable Intent intent, Content notification, String recipeId);
    void getCouponNotification(@Nullable Intent intent, Coupon notification, String recipeId);
    void getCustomJSONNotification(@Nullable Intent intent, CustomJSON notification, String recipeId);
    void getSimpleNotification(@Nullable Intent intent, SimpleNotification s_notif, String recipeId);
    void getFeedbackNotification(@Nullable Intent intent, Feedback s_notif, String recipeId);
}

Add nullable to corecontentlistner methods parameters


package data;

import util.UserAuthUtil;

/** Class to build Login/Logout response objects in JSON format */
public class ResponseBuilder {
  /**
   * @param isLoggedIn user login status
   * @param redirectURL URL to redirect after login/logout
   * @return JSON string with login/logout URL
   *         e.g., logged in: { "isLoggedIn":{"/_ah/logout?continue=%2FLogin"}, "isLoggedOut":{""}}
   *         logged out: { "isLoggedIn":{""}, "isLoggedOut":{"/_ah/login?continue=%2FLogin"}}
   */
  public static String toJson(boolean isLoggedIn, String redirectURL) {
    return "{ \"isLoggedIn\":{\"" + buildLogout(isLoggedIn, redirectURL) + "\"}, " +
            "\"isLoggedOut\":{\"" + buildLogin(isLoggedIn, redirectURL) + "\"}}";
  }

  private static String buildLogin(boolean isLoggedIn, String redirectURL) {
    return isLoggedIn ? "" : UserAuthUtil.getLoginURL(redirectURL);
  }

  private static String buildLogout(boolean isLoggedIn, String redirectURL) {
    return isLoggedIn ? UserAuthUtil.getLogoutURL(redirectURL) : "";
  }
}

package data;

import util.UserAuthUtil;

/** Class to build Login/Logout response objects in JSON format */
public class ResponseBuilder {
  /**
   * @param isLoggedIn user login status
   * @param redirectURL URL to redirect after login/logout
   * @return JSON string with login/logout URL
   *         e.g., logged in: { "isLoggedIn":{"loginURL" : "/_ah/logout?continue=%2FLogin"}, "isLoggedOut":{""}}
   *         logged out: { "isLoggedIn":{""}, "isLoggedOut":{"logoutURL" : "/_ah/login?continue=%2FLogin"}}
   */
  public static String toJson(boolean isLoggedIn, String redirectURL) {
    return "{ \"isLoggedIn\":{\"" + buildLogout(isLoggedIn, redirectURL) + "\"}, " +
            "\"isLoggedOut\":{\"" + buildLogin(isLoggedIn, redirectURL) + "\"}}";
  }

  private static String buildLogin(boolean isLoggedIn, String redirectURL) {
    return isLoggedIn ? "" : "\"loginURL\" :" + UserAuthUtil.getLoginURL(redirectURL);
  }

  private static String buildLogout(boolean isLoggedIn, String redirectURL) {
    return isLoggedIn ? "\"logoutURL\" :" + UserAuthUtil.getLogoutURL(redirectURL) : "";
  }
}

Add key for JSON string

Add key for JSON string


public enum Operator {
	PLUS,MINUS,MULT,DIV,LOW_STRICT,UP_STRICT,LOW_EGAL,UP_EGAL,EGAL,DIFF,AND,OR;
}

public enum Operator {
	PLUS,MINUS,MULT,DIV,LOW_STRICT,UP_STRICT,LOW_EGAL,UP_EGAL,EGAL,DIFF,AND,OR,NOT,OPP;
}

Add 2 operators for the 'not' function

Add 2 operators for the 'not' function


package com.xtremelabs.robolectric.res;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;

public class ResourceExtractor {
    private Map<String, Integer> resourceStringToId = new HashMap<String, Integer>();
    private Map<Integer, String> resourceIdToString = new HashMap<Integer, String>();

    public void addRClass(Class rClass) throws Exception {
        for (Class innerClass : rClass.getClasses()) {
            for (Field field : innerClass.getDeclaredFields()) {
                if (field.getType().equals(Integer.TYPE) && Modifier.isStatic(field.getModifiers())) {
                    String name = innerClass.getSimpleName() + "/" + field.getName();
                    int value = field.getInt(null);
                    resourceStringToId.put(name, value);
                    resourceIdToString.put(value, name);
                }
            }
        }
    }

    public int resourceIdOrZero(String resourceName) {
        Integer resId = getResourceId(resourceName);
        return (resId == null) ? 0 : resId;
    }

    public Integer getResourceId(String resourceName) {
        if (resourceName == null) {
            return null;
        }
        if (resourceName.startsWith("@+id")) {
            resourceName = resourceName.substring(2);
        } else if (resourceName.startsWith("@")) {
            resourceName = resourceName.substring(1);
        }
        return resourceStringToId.get(resourceName);
    }

    public String getResourceName(int resourceId) {
        return resourceIdToString.get(resourceId);
    }
}

package com.xtremelabs.robolectric.res;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;

public class ResourceExtractor {
    private Map<String, Integer> resourceStringToId = new HashMap<String, Integer>();
    private Map<Integer, String> resourceIdToString = new HashMap<Integer, String>();

    public void addRClass(Class rClass) throws Exception {
        for (Class innerClass : rClass.getClasses()) {
            for (Field field : innerClass.getDeclaredFields()) {
                if (field.getType().equals(Integer.TYPE) && Modifier.isStatic(field.getModifiers())) {
                    String name = innerClass.getSimpleName() + "/" + field.getName();
                    int value = field.getInt(null);
                    resourceStringToId.put(name, value);
                    resourceIdToString.put(value, name);
                }
            }
        }
    }

    public int resourceIdOrZero(String resourceName) {
        Integer resId = getResourceId(resourceName);
        return (resId == null) ? 0 : resId;
    }

    public Integer getResourceId(String resourceName) {
        if (resourceName == null) {
            return null;
        }
        if (resourceName.startsWith("@+id")) {
            resourceName = resourceName.substring(2);
        } else if (resourceName.startsWith("@")) {
            resourceName = resourceName.substring(1);
        }
        return resourceStringToId.get(resourceName);
    }

    public String getResourceName(int resourceId) {
        String ret = resourceIdToString.get(resourceId);
        if (ret == null)
            throw new RuntimeException("Can't find resource "+resourceId);
        return ret;
    }
}

Throw RuntimeException if getResourceName() fails


/* This should be a file
*/

public class Example {

	public int i;
	public String test = "TEST";
}
// some new code

Change in file in submodule

Change in file in submodule


package com.iluwatar.generic;

public interface Observer<S extends Observable<S, O, A>, O extends Observer<S, O, A>, A> {
    public void update(S subject, A argument);
}

package com.iluwatar.generic;

public interface Observer<S extends Observable<S, O, A>, O extends Observer<S, O, A>, A> {

    void update(S subject, A argument);
}

[refactor] Remove unnecessary declarations in observer pattern.


package io.sigpipe.sing.stat;

public class SummaryStatistics {

    private double min;
    private double max;
    private double mean;
    private double std;
    private double var;

    public SummaryStatistics(RunningStatistics rs) {
        this.min = rs.min();
        this.max = rs.max();
        this.mean = rs.mean();
        this.var = rs.var();
        this.std = rs.std();
    }

    public double min() {
        return this.min;
    }

    public double max() {
        return this.max;
    }

    public double mean() {
        return this.mean;
    }

    public double std() {
        return this.std;
    }

    public double var() {
        return this.var;
    }
}

package io.sigpipe.sing.stat;

public class SummaryStatistics {

    private long num;
    private double min;
    private double max;
    private double mean;
    private double std;
    private double var;

    public SummaryStatistics(RunningStatistics rs) {
        this.num = rs.n();
        this.min = rs.min();
        this.max = rs.max();
        this.mean = rs.mean();
        this.var = rs.var();
        this.std = rs.std();
    }

    public double num() {
        return this.num;
    }

    public double min() {
        return this.min;
    }

    public double max() {
        return this.max;
    }

    public double mean() {
        return this.mean;
    }

    public double std() {
        return this.std;
    }

    public double var() {
        return this.var;
    }
}

Maintain number of samples observed

Maintain number of samples observed