// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.api;

import java.util.Objects;

/**
 * Represents an Athenz Access Token
 *
 * @author bjorncs
 */
public class AthenzAccessToken {

    public static final String HTTP_HEADER_NAME = "Authorization";

    private static final String BEARER_TOKEN_PREFIX = "Bearer ";

    private final String value;

    public AthenzAccessToken(String value) {
        this.value = stripBearerTokenPrefix(value);
    }

    private static String stripBearerTokenPrefix(String rawValue) {
        String stripped = rawValue.strip();
        return stripped.startsWith(BEARER_TOKEN_PREFIX)
                ? stripped.substring(BEARER_TOKEN_PREFIX.length())
                : stripped;
    }

    public String value() { return value; }

    @Override public String toString() { return "AthenzAccessToken{value='" + value + "'}"; }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AthenzAccessToken that = (AthenzAccessToken) o;
        return Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(value);
    }
}

// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.api;

import java.util.Objects;

/**
 * Represents an Athenz Access Token
 *
 * @author bjorncs
 */
public class AthenzAccessToken {

    public static final String HTTP_HEADER_NAME = "Authorization";

    private static final String BEARER_TOKEN_PREFIX = "Bearer ";

    private final String value;

    public AthenzAccessToken(String value) {
        this.value = stripBearerTokenPrefix(value);
    }

    private static String stripBearerTokenPrefix(String rawValue) {
        String stripped = rawValue.strip();
        String prefixRemoved = stripped.startsWith(BEARER_TOKEN_PREFIX)
                ? stripped.substring(BEARER_TOKEN_PREFIX.length()).strip()
                : stripped;
        if (prefixRemoved.isBlank()) {
            throw new IllegalArgumentException(String.format("Access token is blank: '%s'", prefixRemoved));
        }
        return prefixRemoved;
    }

    public String value() { return value; }

    @Override public String toString() { return "AthenzAccessToken{value='" + value + "'}"; }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AthenzAccessToken that = (AthenzAccessToken) o;
        return Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(value);
    }
}

Access tokens should not be an empty string


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

package com.facebook.fresco.vito.core;

import javax.annotation.Nullable;

/** Fresco experiment class with default values. Override this class to change them. */
public class FrescoExperiments {

  public boolean prepareImagePipelineComponents() {
    return false;
  }

  public boolean checkCacheInAttach() {
    return true;
  }

  public int mountContentPoolSize() {
    // Default Litho mount pool size
    return 3;
  }

  public boolean mountContentPoolSync() {
    // Default Litho mount pool sync value
    return true;
  }

  public boolean prefetchInOnPrepare() {
    return false;
  }

  public boolean keepRefToPrefetchDatasouce() {
    return false;
  }

  public boolean prepareActualImageWrapperInBackground() {
    return true;
  }

  public boolean preparePlaceholderDrawableInBackground() {
    return false;
  }

  public boolean keepRefToMainFetchDatasouce() {
    return true;
  }

  public @Nullable Boolean prefetchToBitmapCache() {
    return null;
  }

  public boolean closeDatasource() {
    return true;
  }

  public boolean cacheImageInState() {
    return false;
  }

  public boolean shouldDiffCallerContext() {
    return false;
  }

  public void setupPropDiffingExperiment() {}

  public boolean fadeInImages() {
    return false;
  }
}

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

package com.facebook.fresco.vito.core;

import javax.annotation.Nullable;

/** Fresco experiment class with default values. Override this class to change them. */
public class FrescoExperiments {

  public boolean prepareImagePipelineComponents() {
    return false;
  }

  public boolean checkCacheInAttach() {
    return true;
  }

  public int mountContentPoolSize() {
    // Default Litho mount pool size
    return 3;
  }

  public boolean mountContentPoolSync() {
    // Default Litho mount pool sync value
    return true;
  }

  public boolean prefetchInOnPrepare() {
    return false;
  }

  public boolean keepRefToPrefetchDatasouce() {
    return false;
  }

  public boolean prepareActualImageWrapperInBackground() {
    return true;
  }

  public boolean preparePlaceholderDrawableInBackground() {
    return false;
  }

  public boolean keepRefToMainFetchDatasouce() {
    return true;
  }

  public @Nullable Boolean prefetchToBitmapCache() {
    return null;
  }

  public boolean closeDatasource() {
    return true;
  }

  public boolean cacheImageInState() {
    return false;
  }

  public boolean shouldDiffCallerContext() {
    return false;
  }

  public void setupPropDiffingExperiment() {}

  public boolean fadeInImages() {
    return false;
  }

  public boolean useBindCallbacks() {
    return false;
  }
}

Add options to use bind/unbind callbacks as opposed to mount/unmount


/*
 * Copyright 2016 The Error Prone 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 com.google.errorprone.annotations;

import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.METHOD;

import java.lang.annotation.Documented;
import java.lang.annotation.Target;

/**
 * Annotation for constructors of AutoCloseables or methods that return an AutoCloseable and require
 * that the resource is closed.
 *
 *
This is enforced by checking that invocations occur within the resource variable initializer
 * of a try-with-resources statement, which guarantees that the resource is always closed. The
 * analysis may be improved in the future to recognize other patterns where the resource will always
 * be closed.
 *
 *
Note that Android SDK versions prior to 19 do not support try-with-resources, so the
 * annotation should be avoided on APIs that may be used on Android.
 */
@Documented
@Target({CONSTRUCTOR, METHOD})
public @interface MustBeClosed {}

/*
 * Copyright 2016 The Error Prone 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 com.google.errorprone.annotations;

import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.METHOD;

import java.lang.annotation.Documented;
import java.lang.annotation.Target;

/**
 * Annotation for constructors of AutoCloseables or methods that return an AutoCloseable and require
 * that the resource is closed.
 *
 *
This is enforced by checking that invocations occur within the resource variable initializer
 * of a try-with-resources statement, which guarantees that the resource is always closed. The
 * analysis may be improved in the future to recognize other patterns where the resource will always
 * be closed.
 *
 *
Note that Android SDK versions prior to 19 do not support try-with-resources, so the
 * annotation should be avoided on APIs that may be used on Android, unless desugaring is used.
 */
@Documented
@Target({CONSTRUCTOR, METHOD})
public @interface MustBeClosed {}

Update javadoc to cover desugaring


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

/**
 * Creates Manager objects.
 * @param <F> The Manager type.
 * @param <T> The Factory data type.
 */
public interface ManagerFactory<F, T> {

    /**
     * Creates a Manager.
     * @param name The name of the entity to manage.
     * @param data The data required to create the entity.
     * @return A Manager for the entity.
     */
    F createManager(String name, T data);
}

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

/**
 * Creates Manager objects.
 * @param <M> The Manager type.
 * @param <T> The Factory data type.
 */
public interface ManagerFactory<M, T> {

    /**
     * Creates a Manager.
     * @param name The name of the entity to manage.
     * @param data The data required to create the entity.
     * @return A Manager for the entity.
     */
    M createManager(String name, T data);
}

Rename parameter type F to M for "Manager".


package day01;

import common.BaseSolution;
import common.InputReader;

public class Solution extends BaseSolution implements common.Solution {

    public static void main(String[] args) {
        new Solution().run();
    }

    public String part1() {
        int mass, totalFuel = 0;
        InputReader reader = getInputReader();
        String line = reader.next();
        while (line != null) {
            mass = Integer.parseInt(line);
            totalFuel += getFuel(mass);
            line = reader.next();
        }
        return String.valueOf(totalFuel);
    }

    private int getFuel(int mass) {
        return mass / 3 - 2;
    }

    public String part2() {
        int mass, totalFuel = 0;
        InputReader reader = getInputReader();
        String line = reader.next();
        while (line != null) {
            mass = Integer.parseInt(line);
            totalFuel += getFuelWithResiduals(mass);
            line = reader.next();
        }
        return String.valueOf(totalFuel);
    }

    private int getFuelWithResiduals(int mass) {
        int fuel = 0;
        int fuelPiece = mass;
        do {
            fuelPiece = getFuel(fuelPiece);
            if (fuelPiece > 0) {
                fuel += fuelPiece;
            }
        } while (fuelPiece > 0);
        return fuel;
    }
}

package day01;

import common.BaseSolution;
import common.InputReader;

public class Solution extends BaseSolution implements common.Solution {

    public static void main(String[] args) {
        new Solution().run();
    }

    class BaseFuelCalculator {
        public int calculateFuel() {
            int mass, totalFuel = 0;
            InputReader reader = getInputReader();
            String line = reader.next();
            while (line != null) {
                mass = Integer.parseInt(line);
                totalFuel += getFuel(mass);
                line = reader.next();
            }
            return totalFuel;
        }

        protected int getFuelForMass(int mass) {
            return mass / 3 - 2;
        }

        protected int getFuel(int mass) {
            return 0;
        }
    }

    class Part1FuelCalculator extends BaseFuelCalculator {
        protected int getFuel(int mass) {
            return getFuelForMass(mass);
        }
    }

    class Part2FuelCalculator extends BaseFuelCalculator {
        protected int getFuel(int mass) {
            int fuel = 0;
            int fuelPiece = mass;
            do {
                fuelPiece = getFuelForMass(fuelPiece);
                if (fuelPiece > 0) {
                    fuel += fuelPiece;
                }
            } while (fuelPiece > 0);
            return fuel;
        }
    }

    public String part1() {
        return String.valueOf(new Part1FuelCalculator().calculateFuel());
    }

    public String part2() {
        return String.valueOf(new Part2FuelCalculator().calculateFuel());
    }
}

Refactor day 1 into reusable FuelCalculator resources


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

package com.googlesource.gerrit.plugins.replication;

import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.GroupMembership;

public class RemoteSiteUser extends CurrentUser {
  private final GroupMembership effectiveGroups;

  public RemoteSiteUser(GroupMembership authGroups) {
    effectiveGroups = authGroups;
  }

  @Override
  public GroupMembership getEffectiveGroups() {
    return effectiveGroups;
  }

  @Override
  public Object getCacheKey() {
    // Never cache a remote user
    return new Object();
  }
}

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

package com.googlesource.gerrit.plugins.replication;

import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.GroupMembership;

public class RemoteSiteUser extends CurrentUser {
  private final GroupMembership effectiveGroups;

  public RemoteSiteUser(GroupMembership authGroups) {
    effectiveGroups = authGroups;
  }

  @Override
  public GroupMembership getEffectiveGroups() {
    return effectiveGroups;
  }
}

Adjust to changes in Gerrit core


package com.elmakers.mine.bukkit.protection;

import me.NoChance.PvPManager.PvPManager;
import me.NoChance.PvPManager.PvPlayer;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

/**
 * This a manager specifically for the PvPManager plugin.
 *
 * This is why it has kind of a funky name.
 */
public class PvPManagerManager implements PVPManager {

    private boolean enabled = false;
    private PvPManager manager = null;

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public boolean isEnabled() {
        return enabled && manager != null;
    }

    public void initialize(Plugin plugin) {
        if (enabled) {
            try {
                Plugin pvpPlugin = plugin.getServer().getPluginManager().getPlugin("PvPManager");
                if (pvpPlugin instanceof PvPManager) {
                    manager = (PvPManager)pvpPlugin;
                }
            } catch (Throwable ex) {
            }

            if (manager != null) {
                plugin.getLogger().info("PvPManager found, will respect PVP settings");
            }
        } else {
            manager = null;
        }
    }

    @Override
    public boolean isPVPAllowed(Player player, Location location) {
        if (!enabled || manager == null || player == null) return true;

        PvPlayer pvpPlayer = manager.getPlayerHandler().get(player);
        return pvpPlayer != null && pvpPlayer.hasPvPEnabled();
    }
}

package com.elmakers.mine.bukkit.protection;

import me.NoChance.PvPManager.PvPManager;
import me.NoChance.PvPManager.PvPlayer;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

/**
 * This a manager specifically for the PvPManager plugin.
 *
 * This is why it has kind of a funky name.
 */
public class PvPManagerManager implements PVPManager {

    private boolean enabled = false;
    private PvPManager manager = null;

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public boolean isEnabled() {
        return enabled && manager != null;
    }

    public void initialize(Plugin plugin) {
        if (enabled) {
            try {
                Plugin pvpPlugin = plugin.getServer().getPluginManager().getPlugin("PvPManager");
                if (pvpPlugin instanceof PvPManager) {
                    manager = (PvPManager)pvpPlugin;
                }
            } catch (Throwable ex) {
            }

            if (manager != null) {
                plugin.getLogger().info("PvPManager found, will respect PVP settings");
            }
        } else {
            manager = null;
        }
    }

    @Override
    public boolean isPVPAllowed(Player player, Location location) {
        if (!enabled || manager == null || player == null) return true;

        PvPlayer pvpPlayer = PvPlayer.get(player);
        return pvpPlayer != null && pvpPlayer.hasPvPEnabled();
    }
}

Fix integration with premium version of PvPManager


package info.u_team.u_team_core.util.registry;

import java.util.function.Supplier;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.*;

public class BlockDeferredRegister {

	public final DeferredRegister<Block> blocks;
	public final DeferredRegister<Item> items;

	public BlockDeferredRegister(String modid) {
		blocks = DeferredRegister.create(ForgeRegistries.BLOCKS, modid);
		items = DeferredRegister.create(ForgeRegistries.ITEMS, modid);
	}

	public <I extends Block> RegistryObject<I> registerCommon(String name, Supplier<? extends I> supplier) {
		return blocks.register(name, supplier);
	}

	public void register(IEventBus bus) {
		blocks.register(bus);
		items.register(bus);
	}

}

package info.u_team.u_team_core.util.registry;

import java.util.function.Supplier;

import org.apache.commons.lang3.tuple.Pair;

import info.u_team.u_team_core.api.registry.IUBlockRegistryType;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.*;

public class BlockDeferredRegister {

	public final DeferredRegister<Block> blocks;
	public final DeferredRegister<Item> items;

	public BlockDeferredRegister(String modid) {
		blocks = DeferredRegister.create(ForgeRegistries.BLOCKS, modid);
		items = DeferredRegister.create(ForgeRegistries.ITEMS, modid);
	}

	public <I extends Block> RegistryObject<I> registerCommon(String name, Supplier<? extends I> supplier) {
		return blocks.register(name, supplier);
	}

	public <I extends Block & IUBlockRegistryType> Pair<RegistryObject<I>, RegistryObject<? extends Item>> register(String name, Supplier<? extends I> supplier) {
		return Pair.of(blocks.register(name, supplier), items.register(name, () -> supplier.get().getBlockItem()));
	}

	public void register(IEventBus bus) {
		blocks.register(bus);
		items.register(bus);
	}

}

Add register method for both


package org.cyclops.integratedtunnels.part;

import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import org.cyclops.integrateddynamics.api.part.PartTarget;
import org.cyclops.integrateddynamics.core.part.write.PartStateWriterBase;
import org.cyclops.integratedtunnels.core.ExtendedFakePlayer;
import org.cyclops.integratedtunnels.core.ItemHandlerPlayerWrapper;

/**
 * A part state for holding a temporary player inventory.
 * @author rubensworks
 */
public class PartStatePlayerSimulator extends PartStateWriterBase<PartTypePlayerSimulator> {

    private ExtendedFakePlayer player = null;

    public PartStatePlayerSimulator(int inventorySize) {
        super(inventorySize);
    }

    public ExtendedFakePlayer getPlayer() {
        return player;
    }

    public void update(PartTarget target) {
        World world = target.getTarget().getPos().getWorld();
        if (!world.isRemote) {
            if (player == null) {
                player = new ExtendedFakePlayer((WorldServer) world);
            }
            ItemHandlerPlayerWrapper.cancelDestroyingBlock(player);
        }
    }
}

package org.cyclops.integratedtunnels.part;

import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import org.cyclops.integrateddynamics.api.part.PartTarget;
import org.cyclops.integrateddynamics.core.part.write.PartStateWriterBase;
import org.cyclops.integratedtunnels.core.ExtendedFakePlayer;
import org.cyclops.integratedtunnels.core.ItemHandlerPlayerWrapper;

/**
 * A part state for holding a temporary player inventory.
 * @author rubensworks
 */
public class PartStatePlayerSimulator extends PartStateWriterBase<PartTypePlayerSimulator> {

    private ExtendedFakePlayer player = null;

    public PartStatePlayerSimulator(int inventorySize) {
        super(inventorySize);
    }

    public ExtendedFakePlayer getPlayer() {
        return player;
    }

    public void update(PartTarget target) {
        World world = target.getTarget().getPos().getWorld();
        if (!world.isRemote) {
            if (player == null) {
                player = new ExtendedFakePlayer((WorldServer) world);
            }
            ItemHandlerPlayerWrapper.cancelDestroyingBlock(player);
        }
    }

    @Override
    protected int getDefaultUpdateInterval() {
        return 10;
    }
}

Set default player simulator tickrate to 10 ticks


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

import org.gradle.api.internal.GradleInternal;

public class InitScriptTarget extends DefaultScriptTarget {
    public InitScriptTarget(GradleInternal target) {
        super(target);
    }

    @Override
    public String getClasspathBlockName() {
        return "initscript";
    }
}

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

import org.gradle.api.internal.GradleInternal;
import org.gradle.groovy.scripts.BasicScript;
import org.gradle.initialization.InitScript;

public class InitScriptTarget extends DefaultScriptTarget {
    public InitScriptTarget(GradleInternal target) {
        super(target);
    }

    @Override
    public Class<? extends BasicScript> getScriptClass() {
        return InitScript.class;
    }

    @Override
    public String getClasspathBlockName() {
        return "initscript";
    }
}

Use correct Script subtypes for init scripts.


package party.lemons.anima.energy;

import net.minecraftforge.energy.IEnergyStorage;

/**
 * Created by Sam on 19/06/2017.
 *
 *  * Anima Energy is basically forge energy, but doesn't accept other energy types
 */
public interface IAnimaStorage extends IEnergyStorage{}

package party.lemons.anima.energy;

import net.minecraftforge.energy.IEnergyStorage;

/**
 * Created by Sam on 19/06/2017.
 *
 *  * Anima Energy is basically forge energy, but doesn't accept other energy types
 */
public interface IAnimaStorage
{

	/**
	 * Adds energy to the storage. Returns quantity of energy that was accepted.
	 *
	 * @param maxReceive
	 *            Maximum amount of energy to be inserted.
	 * @param simulate
	 *            If TRUE, the insertion will only be simulated.
	 * @return Amount of energy that was (or would have been, if simulated) accepted by the storage.
	 */
	int receiveEnergy(int maxReceive, boolean simulate);

	/**
	 * Removes energy from the storage. Returns quantity of energy that was removed.
	 *
	 * @param maxExtract
	 *            Maximum amount of energy to be extracted.
	 * @param simulate
	 *            If TRUE, the extraction will only be simulated.
	 * @return Amount of energy that was (or would have been, if simulated) extracted from the storage.
	 */
	int extractEnergy(int maxExtract, boolean simulate);

	/**
	 * Returns the amount of energy currently stored.
	 */
	int getEnergyStored();

	/**
	 * Returns the maximum amount of energy that can be stored.
	 */
	int getMaxEnergyStored();

	/**
	 * Returns if this storage can have energy extracted.
	 * If this is false, then any calls to extractEnergy will return 0.
	 */
	boolean canExtract();

	/**
	 * Used to determine if this storage can receive energy.
	 * If this is false, then any calls to receiveEnergy will return 0.
	 */
	boolean canReceive();
}

Fix Anima Energy thinking it was Forge Energy


package forager.server;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Handles the active and completed task lists and allows them to be flushed
 * and synced to disk.
 *
 * @author malensek
 */
public class ListManager {

    public static final String DEFAULT_LIST_NAME = "tasklist";

    private FileOutputStream taskListOut;
    private PrintWriter taskListWriter;

    private FileOutputStream completedListOut;
    private PrintWriter completedListWriter;

    public ListManager() throws IOException {
        this(DEFAULT_LIST_NAME);
    }

    public ListManager(String taskListName) throws IOException {
        taskListOut = new FileOutputStream(taskListName, true);
        taskListWriter = new PrintWriter(
                new BufferedOutputStream(taskListOut));

        String completedName = taskListName + ".done";
        completedListOut = new FileOutputStream(completedName, true);
        completedListWriter = new PrintWriter(
                new BufferedOutputStream(completedListOut));
    }

    public void addTask(String command) {
        taskListWriter.println(command);
    }

    public void addCompletedTask(String command) {
        completedListWriter.println(command);
    }

    public void sync() throws IOException {
        taskListWriter.flush();
        taskListOut.getFD().sync();
    }
}

package forager.server;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Handles the active and completed task lists and allows them to be flushed
 * and synced to disk.
 *
 * @author malensek
 */
public class ListManager {

    public static final String DEFAULT_LIST_NAME = "tasklist";

    private FileOutputStream taskListOut;
    private PrintWriter taskListWriter;

    private FileOutputStream completedListOut;
    private PrintWriter completedListWriter;

    public ListManager() throws IOException {
        this(DEFAULT_LIST_NAME);
    }

    public ListManager(String taskListName) throws IOException {
        taskListOut = new FileOutputStream(taskListName, true);
        taskListWriter = new PrintWriter(
                new BufferedOutputStream(taskListOut));

        String completedName = taskListName + ".done";
        completedListOut = new FileOutputStream(completedName, true);
        completedListWriter = new PrintWriter(
                new BufferedOutputStream(completedListOut));
    }

    public void addTask(String command) {
        taskListWriter.println(command);
    }

    public void addCompletedTask(String command) {
        completedListWriter.println(command);
    }

    public void sync() throws IOException {
        taskListWriter.flush();
        taskListOut.getFD().sync();
    }

    public static boolean listsExist() {
        return listsExist(DEFAULT_LIST_NAME);
    }

    public static boolean listsExist(String taskListName) {
        File listFile = new File(taskListName);
        File doneFile = new File(taskListName + ".done");
        return (listFile.exists() || doneFile.exists());
    }
}

Add checks for list files


package Database;

/**
 * This class stores a MySQL credential constants
 */
public enum Config {

    /**
     * Username to MySQL database
     */
    USERNAME("root"),

    /**
     * Password to MySQL database
     */
    PASSWORD("codeKenn"),

    /**
     * Location to MySQL database
     */
    URL("jdbc:mysql://localhost:3306"),

    /**
     * MySQL database to establish connection
     */
    DATABASE("reactiondbtest2"),

    /**
     * MySQL table to query
     */
    TABLE("reactions");

    private String CONSTANT;

    /**
     * Construct this class
     *
     * @param CONSTANT to be set
     */
    private Config(String CONSTANT) {
        this.CONSTANT = CONSTANT;
    }

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

package Database;

/**
 * This class stores a MySQL credential constants
 */
public enum Config {

    /**
     * Username to MySQL database
     */
    USERNAME("root"),

    /**
     * Password to MySQL database
     */
    PASSWORD("codeKenn"),

    /**
     * Location to MySQL database
     */
    URL("jdbc:mysql://localhost:3306"),

    /**
     * MySQL database to establish connection
     */
    DATABASE("reactiondb"),

    /**
     * MySQL table to query
     */
    TABLE("reactions");

    private String CONSTANT;

    /**
     * Construct this class
     *
     * @param CONSTANT to be set
     */
    private Config(String CONSTANT) {
        this.CONSTANT = CONSTANT;
    }

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

Replace database 'reactiondbtest3' with 'reactiondb'


import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class VersionNumbering {
	final static String version = "247";

	static String name = "default";
	static final String slash = System.getProperty("file.separator");
	static String prefix = "default";

	static void updateUpdatr() {

		if( !(new File( "Updatr")).exists() ) {
			(new File( "Updatr")).mkdir();
		}

		try {

			BufferedWriter bw = new BufferedWriter(new FileWriter("Updatr" + slash + name + ".updatr"));

			bw.write( "name=" + name );
			bw.newLine();

			bw.write( "version=" + version );
			bw.newLine();

			bw.write( "url=www.prydwen.net/minec/latest" + prefix + "/" + name + ".updatr");
			bw.newLine();

			bw.write( "file=www.prydwen.net/minec/latest" + prefix + "/" + name + ".updatr");
			bw.newLine();

			bw.write( "notes=");
			bw.newLine();

			bw.close();

		} catch (IOException ioe) {
			ioe.printStackTrace();
		}

	}
}

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class VersionNumbering {
	final static String version = "248";

	static String name = "default";
	static final String slash = System.getProperty("file.separator");
	static String prefix = "default";

	static void updateUpdatr() {

		if( !(new File( "Updatr")).exists() ) {
			(new File( "Updatr")).mkdir();
		}

		try {

			BufferedWriter bw = new BufferedWriter(new FileWriter("Updatr" + slash + name + ".updatr"));

			bw.write( "name=" + name );
			bw.newLine();

			bw.write( "version=" + version );
			bw.newLine();

			bw.write( "url=www.prydwen.net/minec/latest" + prefix + "/" + name + ".updatr");
			bw.newLine();

			bw.write( "file=www.prydwen.net/minec/latest" + prefix + "/" + name + ".updatr");
			bw.newLine();

			bw.write( "notes=");
			bw.newLine();

			bw.close();

		} catch (IOException ioe) {
			ioe.printStackTrace();
		}

	}
}

Refresh sign fix + comments in permissions files + more trimming in permission matching


package EloRating;
public class EloRating {

	public static int newRating(int ratingPlayer, int ratingPlayerTwo, int scorePlayer) {
		double diffRating = ratingPlayerTwo - ratingPlayer;
		double expectedScorePlayer = 1.0/(1.0 + Math.pow(10, ((double)(diffRating))/400.0));
		return (int)( ratingPlayer + calculateKfactor(ratingPlayer)*(scorePlayer - expectedScorePlayer));
	}

	private static int calculateKfactor(int ratingPlayer) {
		if(ratingPlayer<2100) {
			return 32;
		} else if(2100<=ratingPlayer && ratingPlayer<=2400) {
			return 24;
		} else if(ratingPlayer>2400) {
			return 16;
		} else {
			return 0;
		}
	}

	public static void main(String[] args) {
		System.out.println(EloRating.newRating(400, 400, 1));
	}

}

package EloRating;
public class EloRating {
	public static int DEFAULT_ELO;

	public static int newRating(int ratingPlayer, int ratingPlayerTwo, int scorePlayer) {
		double diffRating = ratingPlayerTwo - ratingPlayer;
		double expectedScorePlayer = 1.0/(1.0 + Math.pow(10, ((double)(diffRating))/400.0));
		return (int)( ratingPlayer + calculateKfactor(ratingPlayer)*(scorePlayer - expectedScorePlayer));
	}

	private static int calculateKfactor(int ratingPlayer) {
		if(ratingPlayer<2100) {
			return 32;
		} else if(2100<=ratingPlayer && ratingPlayer<=2400) {
			return 24;
		} else if(ratingPlayer>2400) {
			return 16;
		} else {
			return 0;
		}
	}

	public static void main(String[] args) {
		System.out.println(EloRating.newRating(400, 400, 1));
	}

}

Add constant default elo rating


package com.reactnativenavigation.react;

import android.graphics.drawable.Drawable;

import com.reactnativenavigation.NavigationApplication;

public class ImageLoader {

    public static Drawable loadImage(String iconSource) {
        if (NavigationApplication.instance.isDebug()) {
            return JsDevImageLoader.loadIcon(iconSource);
        } else {
            return ResourceDrawableIdHelper.instance.getResourceDrawable(NavigationApplication.instance, iconSource);
        }
    }
}

package com.reactnativenavigation.react;

import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;

import com.reactnativenavigation.NavigationApplication;

public class ImageLoader {
    private static final String FILE_SCHEME = "file";

    public static Drawable loadImage(String iconSource) {
        if (NavigationApplication.instance.isDebug()) {
            return JsDevImageLoader.loadIcon(iconSource);
        } else {
            Uri uri = Uri.parse(iconSource);
            if (isLocalFile(uri)) {
                return loadFile(uri);
            } else {
                return loadResource(iconSource);
            }
        }
    }

    private static boolean isLocalFile(Uri uri) {
        return FILE_SCHEME.equals(uri.getScheme());
    }

    private static Drawable loadFile(Uri uri) {
        return new BitmapDrawable(NavigationApplication.instance.getResources(), uri.getPath());
    }

    private static Drawable loadResource(String iconSource) {
        return ResourceDrawableIdHelper.instance.getResourceDrawable(NavigationApplication.instance, iconSource);
    }
}

Support loading images from local storage


package de.akquinet.android.androlog.reporter;

import java.util.Properties;

import android.content.Context;

public interface Reporter {

    public abstract void configure(Properties configuration);

    public abstract void send(Context context, String message, Throwable error);

}

package de.akquinet.android.androlog.reporter;

import java.util.Properties;

import de.akquinet.android.androlog.Log;

import android.content.Context;

/**
 * Reporter Interface.
 * A Reporter sends a Report to a specific endpoint
 * (url, mail ...).
 * Reporter instances are created by {@link Log} according
 * to the {@link Log#ANDROLOG_REPORT_REPORTERS} configuration
 * property.
 */
public interface Reporter {

    /**
     * Configures the reporter.
     * Each reporter can define their own configuration properties.
     * @param configuration the Androlog configuration.
     */
    public abstract void configure(Properties configuration);

    /**
     * Asks the reporter to send the report.
     * @param context the Android context
     * @param message a message (optional)
     * @param error a error to attach to the report (optional)
     * @return true if the report was sent correctly,
     * false otherwise.
     */
    public abstract boolean send(Context context, String message, Throwable error);

}

Add javadoc Send return a boolean to detect failed sendings


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

package com.facebook.react.config;

/**
 * Hi there, traveller! This configuration class is not meant to be used by end-users of RN. It
 * contains mainly flags for features that are either under active development and not ready for
 * public consumption, or for use in experiments.
 *
 * These values are safe defaults and should not require manual changes.
 */
public class ReactFeatureFlags {

  /**
   * Whether we should load a specific view manager immediately or when it is accessed by JS
   */
  public static boolean lazilyLoadViewManagers = false;

  /**
   * Reduce the number of Java-JS interops while accessing native arrays
   */
  public static boolean useArrayNativeAccessor = false;

  /**
   * Reduce the number of Java-JS interops while accessing native maps
   */
  public static boolean useMapNativeAccessor = false;

  /**
   * Should this application use TurboModules. If yes, then any module that inherits
   * {@link com.facebook.react.turbomodule.core.interfaces.TurboModule} will NOT be passed in to
   * C++ CatalystInstanceImpl
   */
  public static boolean useTurboModules = false;

  /**
   * Log tags of when a view deleted on the native side
   * {@link com.facebook.react.uimanager.NativeViewHierarchyManager dropView}
   */
  public static boolean logDroppedViews = false;
}

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

package com.facebook.react.config;

/**
 * Hi there, traveller! This configuration class is not meant to be used by end-users of RN. It
 * contains mainly flags for features that are either under active development and not ready for
 * public consumption, or for use in experiments.
 *
 * These values are safe defaults and should not require manual changes.
 */
public class ReactFeatureFlags {

  /**
   * Whether we should load a specific view manager immediately or when it is accessed by JS
   */
  public static boolean lazilyLoadViewManagers = false;

  /**
   * Reduce the number of Java-JS interops while accessing native arrays
   */
  public static boolean useArrayNativeAccessor = false;

  /**
   * Reduce the number of Java-JS interops while accessing native maps
   */
  public static boolean useMapNativeAccessor = false;

  /**
   * Should this application use TurboModules. If yes, then any module that inherits
   * {@link com.facebook.react.turbomodule.core.interfaces.TurboModule} will NOT be passed in to
   * C++ CatalystInstanceImpl
   */
  public static boolean useTurboModules = false;

  /**
   * Log tags of when a view deleted on the native side
   * {@link com.facebook.react.uimanager.NativeViewHierarchyManager dropView}
   */
  public static boolean logDroppedViews = false;

  /*
   * This feature flag enables extra logging on ReactWebViews.
   * Default value is false.
   */
  public static boolean enableExtraWebViewLogs = false;
}

Create feature flag to log extra data in ReactWebView


// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.api;

import java.util.Objects;

/**
 * Represents an Athenz Access Token
 *
 * @author bjorncs
 */
public class AthenzAccessToken {

    public static final String HTTP_HEADER_NAME = "Authorization";

    private static final String BEARER_TOKEN_PREFIX = "Bearer ";

    private final String value;

    public AthenzAccessToken(String value) {
        this.value = stripBearerTokenPrefix(value);
    }

    private static String stripBearerTokenPrefix(String rawValue) {
        String stripped = rawValue.strip();
        String prefixRemoved = stripped.startsWith(BEARER_TOKEN_PREFIX)
                ? stripped.substring(BEARER_TOKEN_PREFIX.length()).strip()
                : stripped;
        if (prefixRemoved.isBlank()) {
            throw new IllegalArgumentException(String.format("Access token is blank: '%s'", prefixRemoved));
        }
        return prefixRemoved;
    }

    public String value() { return value; }

    @Override public String toString() { return "AthenzAccessToken{value='" + value + "'}"; }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AthenzAccessToken that = (AthenzAccessToken) o;
        return Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(value);
    }
}

// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.api;

import java.util.Objects;

/**
 * Represents an Athenz Access Token
 *
 * @author bjorncs
 */
public class AthenzAccessToken {

    public static final String HTTP_HEADER_NAME = "Authorization";

    private static final String BEARER_TOKEN_PREFIX = "Bearer ";

    private final String value;

    public AthenzAccessToken(String value) {
        this.value = stripBearerTokenPrefix(value);
    }

    private static String stripBearerTokenPrefix(String rawValue) {
        String stripped = rawValue.strip();
        String prefixRemoved = stripped.startsWith(BEARER_TOKEN_PREFIX)
                ? stripped.substring(BEARER_TOKEN_PREFIX.length()).strip()
                : stripped;
        if (prefixRemoved.isBlank()) {
            throw new IllegalArgumentException(String.format("Access token is blank: '%s'", prefixRemoved));
        }
        return prefixRemoved;
    }

    public String value() { return value; }
    public String valueWithBearerPrefix() { return BEARER_TOKEN_PREFIX + value; }

    @Override public String toString() { return "AthenzAccessToken{value='" + value + "'}"; }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AthenzAccessToken that = (AthenzAccessToken) o;
        return Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(value);
    }
}

Add getter returning access token with bearer prefix


package org.osgi.test.cases.wireadmin.tbc;

import org.osgi.service.wireadmin.*;

public class FilteredProducerImpl implements Producer {
	protected Wire	wire	= null;

	/**
	 * This method should not be called in the test.
	 *
	 * @return value out of range to indicate the wrong call
	 */
	public Object polled(Wire wire) {
		return new Integer(100);
	}

	public void consumersConnected(Wire[] wires) {
		if (wires != null)
			this.wire = wires[0];
	}

	public void updateWire(int delta, boolean wait) {
		for (int i = 0; i < 10; i += delta) {
			if (wait) {
				try {
					Thread.sleep(100 * i);
				}
				catch (Exception e) {
				}
			}
			wire.update(new Integer(i));
		}
	}
}

package org.osgi.test.cases.wireadmin.tbc;

import org.osgi.service.wireadmin.*;

public class FilteredProducerImpl implements Producer {
	protected Wire	wire	= null;

	/**
	 * This method should not be called in the test.
	 *
	 * @return value out of range to indicate the wrong call
	 */
	public Object polled(Wire wire) {
		return new Integer(100);
	}

	public void consumersConnected(Wire[] wires) {
		if (wires != null)
			this.wire = wires[0];
	}

  public void updateWire(int delta, boolean wait) {
    long processTime = 0;
    for (int i = 0; i < 10; i += delta) {
      if (wait) {
        try {
          if (100*i - processTime > 0) {
            Thread.sleep((100 * i) - processTime);
          }
        }
        catch (Exception e) {
        }
      }
      processTime = System.currentTimeMillis();
      wire.update(new Integer(i));
      processTime = System.currentTimeMillis() - processTime;
    }
  }
}

Fix failure when run on really slow devices/PCs


package io.quarkus.runtime.configuration;

import java.io.Serializable;
import java.util.Map;
import java.util.Set;

import org.eclipse.microprofile.config.spi.ConfigSource;
import org.wildfly.common.Assert;
import org.wildfly.common.annotation.NotNull;

import io.smallrye.config.ConfigSourceMap;

/**
 * A base class for configuration sources which delegate to other configuration sources.
 */
public abstract class AbstractDelegatingConfigSource implements ConfigSource, Serializable {
    private static final long serialVersionUID = -6636734120743034580L;
    protected final ConfigSource delegate;
    protected Map<String, String> propertiesMap;

    /**
     * Construct a new instance.
     *
     * @param delegate the delegate configuration source (must not be {@code null})
     */
    public AbstractDelegatingConfigSource(final ConfigSource delegate) {
        Assert.checkNotNullParam("delegate", delegate);
        this.delegate = delegate;
    }

    /**
     * Get the delegate config source.
     *
     * @return the delegate config source (not {@code null})
     */
    protected @NotNull ConfigSource getDelegate() {
        return delegate;
    }

    public final Map<String, String> getProperties() {
        Map<String, String> propertiesMap = this.propertiesMap;
        if (propertiesMap == null) {
            propertiesMap = this.propertiesMap = new ConfigSourceMap(this);
        }
        return propertiesMap;
    }

    public abstract Set<String> getPropertyNames();

    public String getName() {
        return delegate.getName();
    }

    public int getOrdinal() {
        return delegate.getOrdinal();
    }
}

package io.quarkus.runtime.configuration;

import java.io.Serializable;
import java.util.Map;
import java.util.Set;

import org.eclipse.microprofile.config.spi.ConfigSource;
import org.wildfly.common.Assert;
import org.wildfly.common.annotation.NotNull;

import io.smallrye.config.ConfigSourceMap;

/**
 * A base class for configuration sources which delegate to other configuration sources.
 */
public abstract class AbstractDelegatingConfigSource implements ConfigSource, Serializable {
    private static final long serialVersionUID = -6636734120743034580L;
    protected final ConfigSource delegate;
    private Map<String, String> propertiesMap;

    /**
     * Construct a new instance.
     *
     * @param delegate the delegate configuration source (must not be {@code null})
     */
    public AbstractDelegatingConfigSource(final ConfigSource delegate) {
        Assert.checkNotNullParam("delegate", delegate);
        this.delegate = delegate;
    }

    /**
     * Get the delegate config source.
     *
     * @return the delegate config source (not {@code null})
     */
    protected @NotNull ConfigSource getDelegate() {
        return delegate;
    }

    public final Map<String, String> getProperties() {
        Map<String, String> propertiesMap = this.propertiesMap;
        if (propertiesMap == null) {
            propertiesMap = this.propertiesMap = new ConfigSourceMap(this);
        }
        return propertiesMap;
    }

    public abstract Set<String> getPropertyNames();

    public String getName() {
        return delegate.getName();
    }

    public int getOrdinal() {
        return delegate.getOrdinal();
    }
}

Switch field back to private as it was made protected by mistake


package ge.edu.freeuni.sdp.iot.service.camera_object_recognizer.service;

import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Before;

import javax.ws.rs.core.Application;

import static org.junit.Assert.*;

public class ObjectServiceTest extends JerseyTest {

    @Override
    protected Application configure() {
        return new ResourceConfig(FakeObjectService.class);
    }

    @Before
    public void setUp() throws Exception {

    }

}

package ge.edu.freeuni.sdp.iot.service.camera_object_recognizer.service;

import ge.edu.freeuni.sdp.iot.service.camera_object_recognizer.data.FakeRepository;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Before;
import org.junit.Test;

import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Application;

import static org.junit.Assert.*;

public class ObjectServiceTest extends JerseyTest {

    @Override
    protected Application configure() {
        return new ResourceConfig(FakeObjectService.class);
    }

    @Before
    public void setUp() throws Exception {

    }

    @Test
    public void testGetList_except200emptyList() {

    }

    @Test
    public void testGetList_except200nonemptyList() {

    }

    @Test
    public void testGetList_except404wrongHouseId() {

    }

    @Test
    public void testGetObjectById_except200ObjectDo() {

    }

    @Test
    public void testGetObjectById_except404WrongHouseId() {

    }

    @Test
    public void testGetObjectById_except404WrongObjectId() {

    }

    @Test
    public void testAddObject_except200() {

    }

    @Test
    public void testAddObject_except404WrongHouseId() {

    }

    @Test
    public void testUpdateObjectById_except200UpdatedObjectDo() {

    }

    @Test
    public void testUpdateObjectById_except404WrongHouseId() {

    }

    @Test
    public void testUpdateObjectById_except404WrongObjectId() {

    }

    @Test
    public void testDeleteObjectById_except200() {

    }

    @Test
    public void testDeleteObjectById_except404WrongHouseId() {

    }

    @Test
    public void testDeleteObjectById_except404WrongObjectId() {

    }

    private WebTarget getTarget(String houseId) {
        String path = String.format("/houses/%s", houseId);
        return target(path);
    }

    private WebTarget getTarget(String houseId, String objectId) {
        String path = String.format("/houses/%s/objects/%s", houseId, objectId);
        return target(path);
    }

}

Add stub tests for ObjectService


package uk.co.automatictester.lightning.core.reporters;

import uk.co.automatictester.lightning.core.state.TestSet;

public class TestSetReporter {

    public static String getTestSetExecutionSummaryReport(TestSet testSet) {
        int testCount = testSet.getTestCount();
        int passedTestCount = testSet.getPassCount();
        int failedTestCount = testSet.getFailCount();
        int errorTestCount = testSet.getErrorCount();
        String testSetStatus = getTestSetStatus(testSet);

        return String.format("%n============= EXECUTION SUMMARY =============%n"
                        + "Tests executed:    %s%n"
                        + "Tests passed:      %s%n"
                        + "Tests failed:      %s%n"
                        + "Tests errors:      %s%n"
                        + "Test set status:   %s",
                testCount,
                passedTestCount,
                failedTestCount,
                errorTestCount,
                testSetStatus);
    }

    private static String getTestSetStatus(TestSet testSet) {
        return hasFailed(testSet) ? "FAIL" : "Pass";
    }

    private static boolean hasFailed(TestSet testSet) {
        return testSet.getFailCount() != 0 || testSet.getErrorCount() != 0;
    }
}

package uk.co.automatictester.lightning.core.reporters;

import uk.co.automatictester.lightning.core.state.TestSet;

public class TestSetReporter {

    private TestSetReporter() {
    }

    public static String getTestSetExecutionSummaryReport(TestSet testSet) {
        int testCount = testSet.getTestCount();
        int passedTestCount = testSet.getPassCount();
        int failedTestCount = testSet.getFailCount();
        int errorTestCount = testSet.getErrorCount();
        String testSetStatus = getTestSetStatus(testSet);

        return String.format("%n============= EXECUTION SUMMARY =============%n"
                        + "Tests executed:    %s%n"
                        + "Tests passed:      %s%n"
                        + "Tests failed:      %s%n"
                        + "Tests errors:      %s%n"
                        + "Test set status:   %s",
                testCount,
                passedTestCount,
                failedTestCount,
                errorTestCount,
                testSetStatus);
    }

    private static String getTestSetStatus(TestSet testSet) {
        return hasFailed(testSet) ? "FAIL" : "Pass";
    }

    private static boolean hasFailed(TestSet testSet) {
        return testSet.getFailCount() != 0 || testSet.getErrorCount() != 0;
    }
}

Enforce non-instantiability of utility classes with private constructors


package com.github.aureliano.verbum_domini.web.ui;

import java.io.IOException;

import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;

import com.github.aureliano.verbum_domini.helper.UrlHelper;

@FacesComponent(
		value = "com.github.aureliano.verbum_domini.web.ui.HtmlStyleSheet",
		tagName = "styleSheet", createTag = true
	)
public class HtmlStyleSheet extends UIComponentBase {

	public HtmlStyleSheet() {
		super();
	}

	@Override
	public String getFamily() {
		return "custom.ui.verbum_domini";
	}

	@Override
	public void encodeBegin(FacesContext facesContext) throws IOException {
		StringBuilder tag = new StringBuilder();

		tag.append("<link rel=\"stylesheet\" type=\"text/css\"");

		String source = (String) super.getAttributes().get("source");
		if (source != null) {
			String url = UrlHelper.buildWebAppUrl("css/" + source + ".css");
			tag.append(" href=\"" + url + "\"");
		}

		String media = (String) super.getAttributes().get("media");
		if (media != null) {
			tag.append(" media=\"" + media + "\"");
		}

		tag.append("/>");

		facesContext.getResponseWriter().write(tag.toString());
	}
}

package com.github.aureliano.verbum_domini.web.ui;

import java.io.IOException;

import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;

import com.github.aureliano.verbum_domini.helper.UrlHelper;

@FacesComponent(
		value = "com.github.aureliano.verbum_domini.web.ui.HtmlStyleSheet",
		tagName = "styleSheet", createTag = true
	)
public class HtmlStyleSheet extends UIComponentBase {

	public HtmlStyleSheet() {
		super();
	}

	@Override
	public String getFamily() {
		return "custom.ui.verbum_domini";
	}

	@Override
	public void encodeBegin(FacesContext facesContext) throws IOException {
		StringBuilder tag = new StringBuilder();

		tag.append("<link rel=\"stylesheet\" type=\"text/css\"");

		String source = (String) super.getAttributes().get("source");
		if (source != null) {
			String url = UrlHelper.buildWebAppUrl("/css/" + source + ".css");
			tag.append(" href=\"" + url + "\"");
		}

		String media = (String) super.getAttributes().get("media");
		if (media != null) {
			tag.append(" media=\"" + media + "\"");
		}

		tag.append("/>");

		facesContext.getResponseWriter().write(tag.toString());
	}
}

Set style sheet link path.


/* 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.sync.login;

/**
 * A Exception that occurs while a user tries to log in to, or access their Firefox Sync account.
 *
 * Note that the exceptions returned by {@link #getCause()} may include user info like email addresses
 * so be careful how you log them.
 * todo: ^ do we want to strip the stuff ourselves?
 */
public class FirefoxSyncLoginException extends Exception {
    private final FailureReason failureReason;

    FirefoxSyncLoginException(final String message, final FailureReason failureReason) {
        super(message);
        this.failureReason = failureReason;
    }

    FirefoxSyncLoginException(final Throwable cause, final FailureReason failureReason) {
        super(cause);
        this.failureReason = failureReason; // TODO: add message?
    }

    /**
     * Gets the reason this exception was thrown. Normally, this would be handled by the type of the exception thrown
     * but because these Exceptions are not thrown but passed by callback, this is used instead.
     *
     * @return the reason this exception was thrown.
     */
    public FailureReason getFailureReason() { return failureReason; }

    public enum FailureReason {
        ACCOUNT_NEEDS_VERIFICATION, // TODO: how to document these for public use?
        FAILED_TO_LOAD_ACCOUNT,
        SERVER_RESPONSE_UNEXPECTED,
        UNKNOWN,
    }
}

/* 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.sync.login;

/**
 * A Exception that occurs while a user tries to log in to, or access their Firefox Sync account.
 *
 * Note that the exceptions returned by {@link #getCause()} may include user info like email addresses
 * so be careful how you log them.
 * todo: ^ do we want to strip the stuff ourselves?
 */
public class FirefoxSyncLoginException extends Exception {
    private final FailureReason failureReason;

    FirefoxSyncLoginException(final String message, final FailureReason failureReason) {
        super(message + ". " + failureReason.toString());
        this.failureReason = failureReason;
    }

    FirefoxSyncLoginException(final Throwable cause, final FailureReason failureReason) {
        super(failureReason.toString(), cause);
        this.failureReason = failureReason;
    }

    /**
     * Gets the reason this exception was thrown. Normally, this would be handled by the type of the exception thrown
     * but because these Exceptions are not thrown but passed by callback, this is used instead.
     *
     * @return the reason this exception was thrown.
     */
    public FailureReason getFailureReason() { return failureReason; }

    public enum FailureReason {
        ACCOUNT_NEEDS_VERIFICATION, // TODO: how to document these for public use?
        FAILED_TO_LOAD_ACCOUNT,
        SERVER_RESPONSE_UNEXPECTED,
        UNKNOWN,
    }
}

Add reason to exception detail.


/*
 * Created on Jan 24, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.opennms.core.utils;

import java.util.Calendar;
import java.util.Properties;

import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import junit.framework.TestCase;
import alt.dev.jmta.JMTA;

/**
 * @author david
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class JavaMailerTest extends TestCase {

    public void testMTA() throws Exception {

        Properties props = new Properties();
        Session session = Session.getInstance(props, null);
        MimeMessage message = new MimeMessage(session);
        message.setContent("Hello", "text/plain");
        message.setText("Hello");
        message.setSubject(Calendar.getInstance().getTime() + ": testMTA message");

        String to = "david@opennms.org";
        String from = "david@opennms.org";

        Address address = new InternetAddress(from);
        message.setFrom(address);
        address = new InternetAddress(to);
        message.setRecipients(Message.RecipientType.TO, to);
        message.saveChanges();

        JMTA.send(message);

    }

}

/*
 * Created on Jan 24, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.opennms.core.utils;

/*
import java.util.Calendar;
import java.util.Properties;

import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import alt.dev.jmta.JMTA;
*/
import junit.framework.TestCase;

/**
 * @author david
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class JavaMailerTest extends TestCase {

 /*   public void testMTA() throws Exception {

        Properties props = new Properties();
        Session session = Session.getInstance(props, null);
        MimeMessage message = new MimeMessage(session);
        message.setContent("Hello", "text/plain");
        message.setText("Hello");
        message.setSubject(Calendar.getInstance().getTime() + ": testMTA message");

        String to = "david@opennms.org";
        String from = "david@opennms.org";

        Address address = new InternetAddress(from);
        message.setFrom(address);
        address = new InternetAddress(to);
        message.setRecipients(Message.RecipientType.TO, to);
        message.saveChanges();

        JMTA.send(message);

    }
*/
}

Comment testMTA() test case to prevent sending mail on every build.


package com.kodcu.other;

import javafx.stage.FileChooser;

/**
 * Created by usta on 23.08.2015.
 */
public class ExtensionFilters {

    public final static FileChooser.ExtensionFilter HTML = new FileChooser.ExtensionFilter("HTML", "*.html");
    public final static FileChooser.ExtensionFilter PDF = new FileChooser.ExtensionFilter("PDF", "*.pdf");
    public final static FileChooser.ExtensionFilter DOCBOOK = new FileChooser.ExtensionFilter("DOCBOOK", "*.xml");
    public final static FileChooser.ExtensionFilter EPUB = new FileChooser.ExtensionFilter("EPUB", "*.epub");
    public final static FileChooser.ExtensionFilter MOBI = new FileChooser.ExtensionFilter("MOBI", "*.mobi");
    public final static FileChooser.ExtensionFilter ODT = new FileChooser.ExtensionFilter("ODT", "*.odt");
}

package com.kodcu.other;

import javafx.stage.FileChooser;

/**
 * Created by usta on 23.08.2015.
 */
public class ExtensionFilters {

    public final static FileChooser.ExtensionFilter HTML = new FileChooser.ExtensionFilter("HTML", "*.html");
    public final static FileChooser.ExtensionFilter PDF = new FileChooser.ExtensionFilter("PDF", "*.pdf");
    public final static FileChooser.ExtensionFilter DOCBOOK = new FileChooser.ExtensionFilter("DOCBOOK", "*.xml");
    public final static FileChooser.ExtensionFilter EPUB = new FileChooser.ExtensionFilter("EPUB", "*.epub");
    public final static FileChooser.ExtensionFilter MOBI = new FileChooser.ExtensionFilter("MOBI", "*.mobi");
    public final static FileChooser.ExtensionFilter ODT = new FileChooser.ExtensionFilter("ODT", "*.odt");
    public final static FileChooser.ExtensionFilter ASCIIDOC = new FileChooser.ExtensionFilter("AsciiDoc", "*.adoc", "*.asciidoc", "*.asc", "*.ad", "*.txt", "*.*");
    public final static FileChooser.ExtensionFilter MARKDOWN = new FileChooser.ExtensionFilter("Markdown", "*.md", "*.markdown", "*.txt", "*.*");

}

Update ExtensionFilter for asciidoc and markdown


package com.mijecu25.dsa;

import org.junit.Assert;
import org.junit.Test;

/**
 * This is the Node test class.
 *
 * @author Miguel Velez
 * @version 0.2.1
 *
 */
public class TestNode {
	Node node = new Node(6, null);

	/**
	 * Test the node constructor.
	 */
	@Test
	public void TestNodeConstructor() {
		// Check if they are the same class
		Assert.assertSame(Node.class, this.node.getClass());

		// Check if they are the same class
		Assert.assertNotSame(String.class, this.node.getClass());
	}

	/**
	 * Test the get data method.
	 */
	@Test
	public void TestGetData() {
		// Checking if we get the same data back
		Assert.assertEquals(6, this.node.getData());

		// Check if we do not get the same data back
		Assert.assertNotEquals(5, this.node.getData());
	}

}

package com.mijecu25.dsa;

import org.junit.Assert;
import org.junit.Test;

/**
 * This is the Node test class.
 *
 * @author Miguel Velez
 * @version 0.3
 *
 */
public class TestNode {
	Node first = new Node(6, null);
	Node second = new Node("Dog", null);

	/**
	 * Test the node constructor.
	 */
	@Test
	public void TestNodeConstructor() {
		// Check if they are the same class
		Assert.assertSame(Node.class, this.first.getClass());

		// Check if they are the same class
		Assert.assertNotSame(String.class, this.first.getClass());
	}

	/**
	 * Test the get data method.
	 */
	@Test
	public void TestGetData() {
		// Checking if we get the same data back
		Assert.assertEquals(6, this.first.getData());

		// Check if we do not get the same data back
		Assert.assertNotEquals(5, this.first.getData());
	}

	/**
	 * Test the get next method
	 */
	@Test
	public void TestSetGetNext() {
		// Set second as first's next
		first.setNext(second);

		// Check if the next node is the second node
		Assert.assertEquals(second, first.getNext());

		// Check if that the next node of second is not first
		Assert.assertNotEquals(first, second.getNext());
	}

}

Test get and set next node


package com.novoda.downloadmanager;

import java.util.Timer;
import java.util.TimerTask;

class CallbackThrottleByTime implements CallbackThrottle {

    private final long periodInMillis;

    private static final long DELAY = 0;

    private DownloadBatchStatus downloadBatchStatus;
    private Timer timer;
    private TimerTask timerTask;
    private DownloadBatchCallback callback;

    CallbackThrottleByTime(long periodInMillis) {
        this.periodInMillis = periodInMillis;
    }

    @Override
    public void setCallback(final DownloadBatchCallback callback) {
        this.callback = callback;
        timerTask = new TimerTask() {
            @Override
            public void run() {
                callback.onUpdate(downloadBatchStatus);
            }
        };
    }

    @Override
    public void update(DownloadBatchStatus downloadBatchStatus) {
        if (timerTask == null) {
            return;
        }

        this.downloadBatchStatus = downloadBatchStatus;
        startUpdateIfNecessary();
    }

    private void startUpdateIfNecessary() {
        if (timer == null) {
            timer = new Timer();
            timer.scheduleAtFixedRate(timerTask, DELAY, periodInMillis);
        }
    }

    @Override
    public void stopUpdates() {
        if (callback != null) {
            callback.onUpdate(downloadBatchStatus);
        }

        if (timer != null) {
            timer.cancel();
            timer = null;
        }
    }
}

package com.novoda.downloadmanager;

import java.util.Timer;
import java.util.TimerTask;

class CallbackThrottleByTime implements CallbackThrottle {

    private static final long DELAY_IN_MILLIS = 0;

    private DownloadBatchStatus downloadBatchStatus;
    private Timer timer;
    private TimerTask timerTask;
    private final long periodInMillis;
    private DownloadBatchCallback callback;

    CallbackThrottleByTime(long periodInMillis) {
        this.periodInMillis = periodInMillis;
    }

    @Override
    public void setCallback(final DownloadBatchCallback callback) {
        this.callback = callback;
        timerTask = new TimerTask() {
            @Override
            public void run() {
                callback.onUpdate(downloadBatchStatus);
            }
        };
    }

    @Override
    public void update(DownloadBatchStatus downloadBatchStatus) {
        if (timerTask == null) {
            return;
        }

        this.downloadBatchStatus = downloadBatchStatus;
        startUpdateIfNecessary();
    }

    private void startUpdateIfNecessary() {
        if (timer == null) {
            timer = new Timer();
            timer.scheduleAtFixedRate(timerTask, DELAY_IN_MILLIS, periodInMillis);
        }
    }

    @Override
    public void stopUpdates() {
        if (callback != null) {
            callback.onUpdate(downloadBatchStatus);
        }

        if (timer != null) {
            timer.cancel();
            timer = null;
        }
    }
}

Add time unit to DELAY.


package com.davidferrand.subappbarpanelsample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;

import com.davidferrand.subappbarpanel.SubAppBarPanel;

public class MainActivity extends AppCompatActivity {
    private Toolbar toolbar;
    private SubAppBarPanel panel;

    private ImageView expandIndicator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        toolbar = (Toolbar) findViewById(R.id.main_toolbar);
        panel = (SubAppBarPanel) findViewById(R.id.main_panel);
        expandIndicator = (ImageView) findViewById(R.id.main_toolbar_indicator);

        setSupportActionBar(toolbar);

        toolbar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                panel.toggle();
            }
        });

        panel.setOnPanelMovementListener(new SubAppBarPanel.OnPanelMovementListener() {
            @Override
            public void onPanelMovementStarted(boolean expanding) {
                expandIndicator.setImageResource(expanding ?
                        R.drawable.ic_expand_less_white_24dp :
                        R.drawable.ic_expand_more_white_24dp);
            }

            @Override
            public void onPanelMovementEnded(boolean expanded) {

            }
        });
    }
}

package com.davidferrand.subappbarpanelsample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.davidferrand.subappbarpanel.SubAppBarPanel;

public class MainActivity extends AppCompatActivity {
    private Toolbar toolbar;
    private SubAppBarPanel panel;

    private ImageView expandIndicator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        toolbar = (Toolbar) findViewById(R.id.main_toolbar);
        panel = (SubAppBarPanel) findViewById(R.id.main_panel);
        expandIndicator = (ImageView) findViewById(R.id.main_toolbar_indicator);

        setSupportActionBar(toolbar);

        toolbar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                panel.toggle();
            }
        });

        panel.setOnPanelMovementListener(new SubAppBarPanel.OnPanelMovementListener() {
            @Override
            public void onPanelMovementStarted(boolean expanding) {
                Log.v("Panel movement", "The panel is " +
                        (expanding ? "expanding" : "collapsing"));

                expandIndicator.setImageResource(expanding ?
                        R.drawable.ic_expand_less_white_24dp :
                        R.drawable.ic_expand_more_white_24dp);
            }

            @Override
            public void onPanelMovementEnded(boolean expanded) {
                Log.v("Panel movement", "The panel is completely " +
                        (expanded ? "expanded" : "collapsed"));
            }
        });
    }
}

Add logs for listener callbacks


package com.continuuity.examples.countandfilterwords;

import com.continuuity.api.annotation.Output;
import com.continuuity.api.flow.flowlet.AbstractFlowlet;
import com.continuuity.api.flow.flowlet.OutputEmitter;

public class Tokenizer extends AbstractFlowlet {

  @Output("tokens")
  private OutputEmitter<String> tokenOutput;

  @Output("counts")
  private OutputEmitter<String> countOutput;

  public void process(String line) {
    // Tokenize and emit each token to the filters
    for (String token : line.split("[ .-]")) {
      tokenOutput.emit(token);
    }
    // Also emit once to the 'all' counter
    countOutput.emit("all");
  }
}

package com.continuuity.examples.countandfilterwords;

import com.continuuity.api.annotation.Output;
import com.continuuity.api.flow.flowlet.AbstractFlowlet;
import com.continuuity.api.flow.flowlet.OutputEmitter;

public class Tokenizer extends AbstractFlowlet {

  @Output("tokens")
  private OutputEmitter<String> tokenOutput;

  @Output("counts")
  private OutputEmitter<String> countOutput;

  public void process(String line) {
    // Tokenize and emit each token to the filters
    for (String token : line.split("[ .-]")) {
      tokenOutput.emit(token);
      // Also emit to the 'all' counter for each token
      countOutput.emit("all");
    }
  }
}

Update to make countAll count tokens not lines


package com.airbnb.aerosolve.core.transforms;

import com.google.common.base.CaseFormat;
import com.typesafe.config.Config;

/**
 * Created by hector_yee on 8/25/14.
 */
public class TransformFactory {
  public static Transform createTransform(Config config, String key) {
    if (config == null || key == null) {
      return null;
    }
    String transformName = config.getString(key + ".transform");
    if (transformName == null) {
      return null;
    }

    String name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, transformName);
    Transform result = null;
    try {
      result = (Transform) Class.forName("com.airbnb.aerosolve.core.transforms." + name + "Transform").newInstance();
      result.configure(config, key);
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    return result;
  }
}

package com.airbnb.aerosolve.core.transforms;

import com.google.common.base.CaseFormat;
import com.typesafe.config.Config;

/**
 * Created by hector_yee on 8/25/14.
 */
public class TransformFactory {
  public static Transform createTransform(Config config, String key) {
    if (config == null || key == null) {
      return null;
    }
    String transformName = config.getString(key + ".transform");
    if (transformName == null) {
      return null;
    }

    String name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, transformName);
    Transform result;
    try {
      result = (Transform) Class.forName("com.airbnb.aerosolve.core.transforms." + name + "Transform").newInstance();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    result.configure(config, key);
    return result;
  }
}

Throw exception if transform not found


// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config;

import com.yahoo.jrt.Method;
import com.yahoo.jrt.Request;

/**
 * Defines methods used for RPC config requests.
 */
public class JRTMethods {

    public static final String configV3getConfigMethodName = "config.v3.getConfig";
    private static final String configV3GetConfigRequestTypes = "s";
    private static final String configV3GetConfigResponseTypes = "sx";
    public static Method createConfigV3GetConfigMethod(Object handler, String handlerMethod) {
        return new Method(configV3getConfigMethodName, configV3GetConfigRequestTypes, configV3GetConfigResponseTypes,
                handler, handlerMethod)
                .methodDesc("get config v3")
                .paramDesc(0, "request", "config request")
                .returnDesc(0, "response", "config response")
                .returnDesc(1, "payload", "config response payload");
    }

    public static boolean checkV3ReturnTypes(Request request) {
        return request.checkReturnTypes(JRTMethods.configV3GetConfigResponseTypes);
    }
}

// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config;

import com.yahoo.jrt.Method;
import com.yahoo.jrt.MethodHandler;
import com.yahoo.jrt.Request;

/**
 * Defines methods used for RPC config requests.
 */
public class JRTMethods {

    public static final String configV3getConfigMethodName = "config.v3.getConfig";
    private static final String configV3GetConfigRequestTypes = "s";
    private static final String configV3GetConfigResponseTypes = "sx";

    public static Method createConfigV3GetConfigMethod(Object handler, String handlerMethod) {
        return addDescriptions(
                new Method(configV3getConfigMethodName, configV3GetConfigRequestTypes, configV3GetConfigResponseTypes, handler, handlerMethod));
    }

    public static Method createConfigV3GetConfigMethod(MethodHandler methodHandler) {
        return addDescriptions(
                new Method(configV3getConfigMethodName, configV3GetConfigRequestTypes, configV3GetConfigResponseTypes, methodHandler));
    }

    private static Method addDescriptions(Method method) {
        return method.methodDesc("get config v3")
                .paramDesc(0, "request", "config request")
                .returnDesc(0, "response", "config response")
                .returnDesc(1, "payload", "config response payload");
    }

    public static boolean checkV3ReturnTypes(Request request) {
        return request.checkReturnTypes(JRTMethods.configV3GetConfigResponseTypes);
    }
}

Add createConfigV3GetConfigMethod overload taking MethodHandler


package ee.tuleva.onboarding.auth;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

@ResponseStatus(value= HttpStatus.CONTINUE, reason="AUTHENTICATION_NOT_COMPLETE") //<- TODO: this is not working
public class MobileIdAuthNotCompleteException extends RuntimeException {
    MobileIdAuthNotCompleteException() {
        super("AUTHENTICATION_NOT_COMPLETE");
    }
}

package ee.tuleva.onboarding.auth;

import org.springframework.security.oauth2.common.exceptions.ClientAuthenticationException;

public class MobileIdAuthNotCompleteException extends ClientAuthenticationException {
    MobileIdAuthNotCompleteException() {
        super("Please keep polling.");
    }

    @Override
    public String getOAuth2ErrorCode() {
        return "AUTHENTICATION_NOT_COMPLETE";
    }

    @Override
    public int getHttpErrorCode() {
        return 200; //TODO: change to something else
    }
}

Fix Mobile keep polling exception


/*
 * Copyright 2015 Bridje Framework.
 *
 * 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.bridje.core.ioc.test;

import org.bridje.core.ioc.ContextListener;
import org.bridje.core.ioc.annotations.Component;

@Component
public class ContextListenerGeneric implements ContextListener<Object>
{
    @Override
    public void preCreateComponent(Class<Object> clazz)
    {
        System.out.println("preCreate: " + clazz.getName());
    }

    @Override
    public void preInitComponent(Class<Object> clazz)
    {
        System.out.println("preInit: " + clazz.getName());
    }

    @Override
    public void postInitComponent(Class<Object> clazz)
    {
        System.out.println("postInit: " + clazz.getName());
    }
}

/*
 * Copyright 2015 Bridje Framework.
 *
 * 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.bridje.core.ioc.test;

import org.bridje.core.ioc.ContextListener;
import org.bridje.core.ioc.annotations.Component;

@Component
public class ContextListenerGeneric implements ContextListener<Object>
{
    @Override
    public void preCreateComponent(Class<Object> clazz)
    {
        System.out.println("General method called for all the components preCreate: " + clazz.getName());
    }

    @Override
    public void preInitComponent(Class<Object> clazz)
    {
        System.out.println("General method called for all the components  preInit: " + clazz.getName());
    }

    @Override
    public void postInitComponent(Class<Object> clazz)
    {
        System.out.println("General method called for all the components  postInit: " + clazz.getName());
    }
}

Change the text on the test


package com.elmakers.mine.bukkit.magicworlds.listener;

import com.elmakers.mine.bukkit.magicworlds.MagicWorld;
import com.elmakers.mine.bukkit.magicworlds.MagicWorldsController;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.plugin.Plugin;

public class EntitySpawnListener implements Listener
{
    private final MagicWorldsController controller;

	public EntitySpawnListener(final MagicWorldsController controller)
	{
        this.controller = controller;
	}

    @EventHandler(priority = EventPriority.LOW)
    public void onEntitySpawn(CreatureSpawnEvent event) {
        if (event.isCancelled()) {
            return;
        }
        if (event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.DEFAULT) return;

        MagicWorld magicWorld = controller.getWorld(event.getLocation().getWorld().getName());
        if (magicWorld == null) return;

        LivingEntity entity = event.getEntity();
        Plugin plugin = controller.getPlugin();
        LivingEntity replace =  magicWorld.processEntitySpawn(plugin, entity);
        if (replace != null) {
        	entity.setHealth(0);
            event.setCancelled(true);
    	}
    }
}

package com.elmakers.mine.bukkit.magicworlds.listener;

import com.elmakers.mine.bukkit.magicworlds.MagicWorld;
import com.elmakers.mine.bukkit.magicworlds.MagicWorldsController;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.plugin.Plugin;

public class EntitySpawnListener implements Listener
{
    private final MagicWorldsController controller;

	public EntitySpawnListener(final MagicWorldsController controller)
	{
        this.controller = controller;
	}

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onEntitySpawn(CreatureSpawnEvent event) {
        if (event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.DEFAULT) return;

        MagicWorld magicWorld = controller.getWorld(event.getLocation().getWorld().getName());
        if (magicWorld == null) return;

        LivingEntity entity = event.getEntity();
        Plugin plugin = controller.getPlugin();
        LivingEntity replace =  magicWorld.processEntitySpawn(plugin, entity);
        if (replace != null) {
        	entity.setHealth(0);
            event.setCancelled(true);
    	}
    }
}

Change priority to ignore cancelled spawn events


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

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

/**
 * A bean that returns a message when you call the {@link #saySomething()} method.
 * <p/>
 * Uses <tt>@Component("myBean")</tt> to register this bean with the name <tt>myBean</tt>
 * that we use in the Camel route to lookup this bean.
 */
@Component("myBean")
public class SampleBean {

    @Value("greeting")
    private String say;

    public String saySomething() {
        return say;
    }

}

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

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

/**
 * A bean that returns a message when you call the {@link #saySomething()} method.
 * <p/>
 * Uses <tt>@Component("myBean")</tt> to register this bean with the name <tt>myBean</tt>
 * that we use in the Camel route to lookup this bean.
 */
@Component("myBean")
public class SampleBean {

    @Value("${greeting}")
    private String say;

    public String saySomething() {
        return say;
    }

}

Move spring-boot-starter-sample to examples so we can collapse the camel-spring-boot-starter module


package de.flux.playground.deckcompare.analyze;

import de.flux.playground.deckcompare.dto.Card;

public final class CardConflictAnalyzer {

    public static boolean conflicted(Card card, Card otherCard) {

        boolean isConflicted = false;

        if (card.equals(otherCard)) {
            int overallQunatity = card.getQty() + otherCard.getQty();
            isConflicted = overallQunatity > 3;
        }

        return isConflicted;
    }

}

package de.flux.playground.deckcompare.analyze;

import de.flux.playground.deckcompare.dto.Card;

public final class CardConflictAnalyzer {

    private CardConflictAnalyzer() {
    }

    public static boolean conflicted(Card card, Card otherCard) {

        boolean isConflicted = false;

        if (card.equals(otherCard)) {
            int overallQunatity = card.getQty() + otherCard.getQty();
            isConflicted = overallQunatity > 3;
        }

        return isConflicted;
    }

}

Add private constructor to prevent instantiation


package com.github.games647.lagmonitor.listeners;

import com.github.games647.lagmonitor.LagMonitor;
import java.io.IOException;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.util.List;
import java.util.logging.Level;

import org.bukkit.Bukkit;

public class BlockingConnectionSelector extends ProxySelector {

    private final LagMonitor plugin;
    private final ProxySelector oldProxySelector;

    public BlockingConnectionSelector(LagMonitor plugin, ProxySelector oldProxySelector) {
        this.plugin = plugin;
        this.oldProxySelector = oldProxySelector;
    }

    @Override
    public List<Proxy> select(URI uri) {
        if (Bukkit.isPrimaryThread()) {
            plugin.getLogger().log(Level.WARNING
                    , "Server is performing a blocking socket connection {0} on the main thread"
                    , new Object[]{uri});
            plugin.getLogger().log(Level.WARNING, "", new Throwable());
        }

        return oldProxySelector.select(uri);
    }

    @Override
    public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
        oldProxySelector.connectFailed(uri, sa, ioe);
    }

    public ProxySelector getOldProxySelector() {
        return oldProxySelector;
    }
}

package com.github.games647.lagmonitor.listeners;

import com.github.games647.lagmonitor.LagMonitor;

import java.io.IOException;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.util.List;
import java.util.logging.Level;

import org.bukkit.Bukkit;

public class BlockingConnectionSelector extends ProxySelector {

    private final LagMonitor plugin;
    private final ProxySelector oldProxySelector;

    public BlockingConnectionSelector(LagMonitor plugin, ProxySelector oldProxySelector) {
        this.plugin = plugin;
        this.oldProxySelector = oldProxySelector;
    }

    @Override
    public List<Proxy> select(URI uri) {
        if (!uri.getScheme().startsWith("http") && Bukkit.isPrimaryThread()) {
            plugin.getLogger().log(Level.WARNING
                    , "Server is performing a blocking socket connection {0} on the main thread"
                    , new Object[]{uri});
            plugin.getLogger().log(Level.WARNING, "", new Throwable());
        }

        return oldProxySelector.select(uri);
    }

    @Override
    public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
        oldProxySelector.connectFailed(uri, sa, ioe);
    }

    public ProxySelector getOldProxySelector() {
        return oldProxySelector;
    }
}

Fix showing duplicate http blocking messages, because a http connection


package org.xcolab.view.pages.contestmanagement.beans;

import org.hibernate.validator.constraints.NotBlank;

import java.io.Serializable;

public class BatchRegisterBean implements Serializable {

    @NotBlank
    private Boolean asGuests;

    @NotBlank
    private String batchText;

    public String getBatchText() {
        return batchText;
    }

    public void setBatchText(String batchText) {
        this.batchText = batchText;
    }

    public Boolean getAsGuests() {
        return asGuests;
    }

    public void setAsGuest(Boolean asGuests) {
        this.asGuests = asGuests;
    }

    @Override
    public String toString() {
        return "BatchRegisterBean [batchText='" + batchText + "', asGuests='" + asGuests.toString() + "']";
    }

}

package org.xcolab.view.pages.contestmanagement.beans;

import org.hibernate.validator.constraints.NotBlank;

import java.io.Serializable;

public class BatchRegisterBean implements Serializable {

    @NotBlank
    private boolean asGuests;

    @NotBlank
    private String batchText;

    public String getBatchText() {
        return batchText;
    }

    public void setBatchText(String batchText) {
        this.batchText = batchText;
    }

    public boolean getAsGuests() {
        return asGuests;
    }

    public void setAsGuest(boolean asGuests) {
        this.asGuests = asGuests;
    }

    @Override
    public String toString() {
        return "BatchRegisterBean [batchText='" + batchText + "', asGuests='" + String.valueOf(asGuests) + "']";
    }

}

Fix null pointer error for asGuests in batchRegister


package com.rejasupotaro.android.kvs.internal;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class StringUtilsTest {
    @Test
    public void testCapitalize() {
        assertThat(StringUtils.capitalize("username")).isEqualTo("Username");
    }
}

package com.rejasupotaro.android.kvs.internal;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class StringUtilsTest {
    @Test
    public void testCapitalize() {
        assertThat(StringUtils.capitalize("username")).isEqualTo("Username");
    }

    @Test
    public void testIsEmpty() {
        assertThat(StringUtils.isEmpty(null)).isTrue();
        assertThat(StringUtils.isEmpty("")).isTrue();
        assertThat(StringUtils.isEmpty("hoge")).isFalse();
    }

}

Add a test for isEmpty.


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

package com.wdullaer.materialdatetimepicker;

import android.content.Context;
import android.util.AttributeSet;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Button;
import android.widget.TextView;

/**
 * Fake Button class, used so TextViews can announce themselves as Buttons, for accessibility.
 */
public class AccessibleTextView extends TextView {

    public AccessibleTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
        super.onInitializeAccessibilityEvent(event);
        event.setClassName(Button.class.getName());
    }

    @Override
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setClassName(Button.class.getName());
    }
}

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

package com.wdullaer.materialdatetimepicker;

import android.content.Context;
import android.util.AttributeSet;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Button;

/**
 * Fake Button class, used so TextViews can announce themselves as Buttons, for accessibility.
 */
public class AccessibleTextView extends androidx.appcompat.widget.AppCompatTextView {

    public AccessibleTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
        super.onInitializeAccessibilityEvent(event);
        event.setClassName(Button.class.getName());
    }

    @Override
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setClassName(Button.class.getName());
    }
}

Make AccessibilityTextView inherit from AppCompatTextView