repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
InfinityRaider/NinjaGear | src/main/java/com/infinityraider/ninjagear/handler/TooltipHandler.java | // Path: src/main/java/com/infinityraider/ninjagear/api/v1/IHiddenItem.java
// public interface IHiddenItem {
// /**
// * Checks whether or not equipping this item will reveal a hidden entity
// * @param entity entity equipping the item
// * @param stack stack holding the item
// * @return true to reveal the player
// */
// boolean shouldRevealPlayerWhenEquipped(PlayerEntity entity, ItemStack stack);
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/capability/CapabilityNinjaArmor.java
// public class CapabilityNinjaArmor implements IInfSerializableCapabilityImplementation<ItemStack, CapabilityNinjaArmor.Impl> {
// private static final CapabilityNinjaArmor INSTANCE = new CapabilityNinjaArmor();
//
// public static CapabilityNinjaArmor getInstance() {
// return INSTANCE;
// }
//
// public static ResourceLocation KEY = new ResourceLocation(Reference.MOD_ID.toLowerCase(), "ninja_gear");
//
// public static boolean isNinjaArmor(ItemStack stack) {
// return stack.getCapability(CapabilityNinjaArmor.CAPABILITY).map(CapabilityNinjaArmor.Impl::isNinjaArmor).orElse(false);
// }
//
// @CapabilityInject(value = Impl.class)
// public static Capability<Impl> CAPABILITY = null;
//
// private CapabilityNinjaArmor() {}
//
// @Override
// public Capability<Impl> getCapability() {
// return CAPABILITY;
// }
//
// @Override
// public boolean shouldApplyCapability(ItemStack stack) {
// return stack.getItem() instanceof ArmorItem;
// }
//
// @Override
// public Impl createNewValue(ItemStack stack) {
// return new Impl(stack);
// }
//
// @Override
// public ResourceLocation getCapabilityKey() {
// return KEY;
// }
//
// @Override
// public Class<ItemStack> getCarrierClass() {
// return ItemStack.class;
// }
//
// @Override
// public Class<Impl> getCapabilityClass() {
// return Impl.class;
// }
//
// public static class Impl implements ISerializable {
// private boolean isNinjaArmor;
//
// private Impl(ItemStack stack) {
// this.isNinjaArmor = stack.getItem() instanceof ItemNinjaArmor;
// }
//
// public boolean isNinjaArmor() {
// return this.isNinjaArmor;
// }
//
// public void setNinjaArmor(boolean value) {
// this.isNinjaArmor = value;
// }
//
// @Override
// public void readFromNBT(CompoundNBT tag) {
// this.isNinjaArmor = tag.contains(Names.NBT.NINJA_GEAR) && tag.getBoolean(Names.NBT.NINJA_GEAR);
// }
//
// @Override
// public CompoundNBT writeToNBT() {
// CompoundNBT tag = new CompoundNBT();
// tag.putBoolean(Names.NBT.NINJA_GEAR, this.isNinjaArmor);
// return tag;
// }
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/reference/Reference.java
// public interface Reference {
//
// String MOD_NAME = /*^${mod.name}^*/ "NinjaGear";
// String MOD_ID = /*^${mod.id}^*/ "ninja_gear";
// String AUTHOR = /*^${mod.author}^*/ "InfinityRaider";
//
// String VER_MAJOR = /*^${mod.version_major}^*/ "2";
// String VER_MINOR = /*^${mod.version_minor}^*/ "0";
// String VER_PATCH = /*^${mod.version_patch}^*/ "1";
// String MOD_VERSION = /*^${mod.version}^*/ "2.0.1";
// String VERSION = /*^${mod.version_minecraft}-${mod.version}^*/ "1.16.5-" + MOD_VERSION;
//
// String UPDATE_URL = /*^${mod.update_url}^*/ "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
//
// }
| import com.infinityraider.ninjagear.api.v1.IHiddenItem;
import com.infinityraider.ninjagear.capability.CapabilityNinjaArmor;
import com.infinityraider.ninjagear.reference.Reference;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.List; | package com.infinityraider.ninjagear.handler;
@OnlyIn(Dist.CLIENT)
public class TooltipHandler {
private static final TooltipHandler INSTANCE = new TooltipHandler();
private static final ITextComponent EMPTY_STRING = new StringTextComponent("");
public static TooltipHandler getInstance() {
return INSTANCE;
}
private TooltipHandler() {
}
@SubscribeEvent
@SuppressWarnings("unused")
public void onTooltipEvent(ItemTooltipEvent event) {
ItemStack stack = event.getItemStack();
if (stack.isEmpty()) {
return;
}
if (stack.getItem() instanceof IHiddenItem) {
this.addTooltipForHiddenItem(event.getToolTip(), (IHiddenItem) stack.getItem(), stack, event.getPlayer());
}
if (CapabilityNinjaArmor.isNinjaArmor(stack)) {
this.addTooltipForNinjaArmor(event.getToolTip());
}
}
private void addTooltipForHiddenItem(List<ITextComponent> tooltip, IHiddenItem item, ItemStack stack, PlayerEntity player) {
if (!item.shouldRevealPlayerWhenEquipped(player, stack)) {
tooltip.add(EMPTY_STRING); | // Path: src/main/java/com/infinityraider/ninjagear/api/v1/IHiddenItem.java
// public interface IHiddenItem {
// /**
// * Checks whether or not equipping this item will reveal a hidden entity
// * @param entity entity equipping the item
// * @param stack stack holding the item
// * @return true to reveal the player
// */
// boolean shouldRevealPlayerWhenEquipped(PlayerEntity entity, ItemStack stack);
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/capability/CapabilityNinjaArmor.java
// public class CapabilityNinjaArmor implements IInfSerializableCapabilityImplementation<ItemStack, CapabilityNinjaArmor.Impl> {
// private static final CapabilityNinjaArmor INSTANCE = new CapabilityNinjaArmor();
//
// public static CapabilityNinjaArmor getInstance() {
// return INSTANCE;
// }
//
// public static ResourceLocation KEY = new ResourceLocation(Reference.MOD_ID.toLowerCase(), "ninja_gear");
//
// public static boolean isNinjaArmor(ItemStack stack) {
// return stack.getCapability(CapabilityNinjaArmor.CAPABILITY).map(CapabilityNinjaArmor.Impl::isNinjaArmor).orElse(false);
// }
//
// @CapabilityInject(value = Impl.class)
// public static Capability<Impl> CAPABILITY = null;
//
// private CapabilityNinjaArmor() {}
//
// @Override
// public Capability<Impl> getCapability() {
// return CAPABILITY;
// }
//
// @Override
// public boolean shouldApplyCapability(ItemStack stack) {
// return stack.getItem() instanceof ArmorItem;
// }
//
// @Override
// public Impl createNewValue(ItemStack stack) {
// return new Impl(stack);
// }
//
// @Override
// public ResourceLocation getCapabilityKey() {
// return KEY;
// }
//
// @Override
// public Class<ItemStack> getCarrierClass() {
// return ItemStack.class;
// }
//
// @Override
// public Class<Impl> getCapabilityClass() {
// return Impl.class;
// }
//
// public static class Impl implements ISerializable {
// private boolean isNinjaArmor;
//
// private Impl(ItemStack stack) {
// this.isNinjaArmor = stack.getItem() instanceof ItemNinjaArmor;
// }
//
// public boolean isNinjaArmor() {
// return this.isNinjaArmor;
// }
//
// public void setNinjaArmor(boolean value) {
// this.isNinjaArmor = value;
// }
//
// @Override
// public void readFromNBT(CompoundNBT tag) {
// this.isNinjaArmor = tag.contains(Names.NBT.NINJA_GEAR) && tag.getBoolean(Names.NBT.NINJA_GEAR);
// }
//
// @Override
// public CompoundNBT writeToNBT() {
// CompoundNBT tag = new CompoundNBT();
// tag.putBoolean(Names.NBT.NINJA_GEAR, this.isNinjaArmor);
// return tag;
// }
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/reference/Reference.java
// public interface Reference {
//
// String MOD_NAME = /*^${mod.name}^*/ "NinjaGear";
// String MOD_ID = /*^${mod.id}^*/ "ninja_gear";
// String AUTHOR = /*^${mod.author}^*/ "InfinityRaider";
//
// String VER_MAJOR = /*^${mod.version_major}^*/ "2";
// String VER_MINOR = /*^${mod.version_minor}^*/ "0";
// String VER_PATCH = /*^${mod.version_patch}^*/ "1";
// String MOD_VERSION = /*^${mod.version}^*/ "2.0.1";
// String VERSION = /*^${mod.version_minecraft}-${mod.version}^*/ "1.16.5-" + MOD_VERSION;
//
// String UPDATE_URL = /*^${mod.update_url}^*/ "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
//
// }
// Path: src/main/java/com/infinityraider/ninjagear/handler/TooltipHandler.java
import com.infinityraider.ninjagear.api.v1.IHiddenItem;
import com.infinityraider.ninjagear.capability.CapabilityNinjaArmor;
import com.infinityraider.ninjagear.reference.Reference;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.List;
package com.infinityraider.ninjagear.handler;
@OnlyIn(Dist.CLIENT)
public class TooltipHandler {
private static final TooltipHandler INSTANCE = new TooltipHandler();
private static final ITextComponent EMPTY_STRING = new StringTextComponent("");
public static TooltipHandler getInstance() {
return INSTANCE;
}
private TooltipHandler() {
}
@SubscribeEvent
@SuppressWarnings("unused")
public void onTooltipEvent(ItemTooltipEvent event) {
ItemStack stack = event.getItemStack();
if (stack.isEmpty()) {
return;
}
if (stack.getItem() instanceof IHiddenItem) {
this.addTooltipForHiddenItem(event.getToolTip(), (IHiddenItem) stack.getItem(), stack, event.getPlayer());
}
if (CapabilityNinjaArmor.isNinjaArmor(stack)) {
this.addTooltipForNinjaArmor(event.getToolTip());
}
}
private void addTooltipForHiddenItem(List<ITextComponent> tooltip, IHiddenItem item, ItemStack stack, PlayerEntity player) {
if (!item.shouldRevealPlayerWhenEquipped(player, stack)) {
tooltip.add(EMPTY_STRING); | tooltip.add(new TranslationTextComponent(Reference.MOD_ID + ".tooltip:hidden_item_L1")); |
InfinityRaider/NinjaGear | src/main/java/com/infinityraider/ninjagear/effect/EffectNinjaHidden.java | // Path: src/main/java/com/infinityraider/ninjagear/reference/Names.java
// public class Names {
// private Names() {}
//
// public static final class Items extends Names {
// public static final String SHURIKEN = "shuriken";
// public static final String KATANA = "katana";
// public static final String SMOKE_BOMB = "smoke_bomb";
// public static final String ROPE = "rope";
// public static final String ROPE_COIL = "rope_coil";
// }
//
// public static final class Effects extends Names {
// public static final String NINJA_HIDDEN = "ninja_hidden";
// public static final String NINJA_REVEALED = "ninja_revealed";
// public static final String NINJA_SMOKED = "ninja_smoked";
// }
//
// public static final class NBT extends Names {
// public static final String CRIT = "NG_crit";
// public static final String NINJA_GEAR = "NG_ninja";
// public static final String X = "NG_X";
// public static final String Y = "NG_Y";
// public static final String Z = "NG_Z";
// }
// }
| import com.infinityraider.infinitylib.effect.EffectBase;
import com.infinityraider.infinitylib.modules.synchronizedeffects.ISynchronizedEffect;
import com.infinityraider.ninjagear.reference.Names;
import net.minecraft.entity.LivingEntity;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.EffectType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.awt.*; | package com.infinityraider.ninjagear.effect;
public class EffectNinjaHidden extends EffectBase implements ISynchronizedEffect {
public EffectNinjaHidden() { | // Path: src/main/java/com/infinityraider/ninjagear/reference/Names.java
// public class Names {
// private Names() {}
//
// public static final class Items extends Names {
// public static final String SHURIKEN = "shuriken";
// public static final String KATANA = "katana";
// public static final String SMOKE_BOMB = "smoke_bomb";
// public static final String ROPE = "rope";
// public static final String ROPE_COIL = "rope_coil";
// }
//
// public static final class Effects extends Names {
// public static final String NINJA_HIDDEN = "ninja_hidden";
// public static final String NINJA_REVEALED = "ninja_revealed";
// public static final String NINJA_SMOKED = "ninja_smoked";
// }
//
// public static final class NBT extends Names {
// public static final String CRIT = "NG_crit";
// public static final String NINJA_GEAR = "NG_ninja";
// public static final String X = "NG_X";
// public static final String Y = "NG_Y";
// public static final String Z = "NG_Z";
// }
// }
// Path: src/main/java/com/infinityraider/ninjagear/effect/EffectNinjaHidden.java
import com.infinityraider.infinitylib.effect.EffectBase;
import com.infinityraider.infinitylib.modules.synchronizedeffects.ISynchronizedEffect;
import com.infinityraider.ninjagear.reference.Names;
import net.minecraft.entity.LivingEntity;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.EffectType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.awt.*;
package com.infinityraider.ninjagear.effect;
public class EffectNinjaHidden extends EffectBase implements ISynchronizedEffect {
public EffectNinjaHidden() { | super(Names.Effects.NINJA_HIDDEN, EffectType.BENEFICIAL, new Color(0, 0, 0).getRGB()); |
InfinityRaider/NinjaGear | src/main/java/com/infinityraider/ninjagear/api/v0/NoAPI.java | // Path: src/main/java/com/infinityraider/ninjagear/api/APIStatus.java
// public enum APIStatus {
// /**
// * The API was not properly initialized. Possible reasons:
// *
// * - You called getAPI() before NinjaGear was initialized. Don't call
// * getAPI() in the PREINIT phase.
// *
// * - Someone included the API with their mod, NinjaGear is not actually
// * installed.
// */
// API_NOT_INITIALIZED,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * You still need to check the version of the returned API object, it may be
// * an older version than you expect.
// *
// * Please note that during the init phases not all methods may return final
// * values.
// */
// OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is fully functional.
// */
// BACKLEVEL_OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is basically functional. Some functionality may be missing.
// */
// BACKLEVEL_LIMITED,
// /**
// * No API object for the API version you requested can be supplied.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got a non-functional API object because the
// * requested version is no longer supported.
// */
// BACKLEVEL_UNSUPPORTED,
// /**
// * An error occurred and no API object could be provided.
// *
// * You sill got a non-functional API object.
// */
// ERROR;
//
// /**
// * Shortcut to check for one of the 3 "OK" states that allow you to work
// * with the API object.
// */
// public boolean isOK() {
// return this == OK || this == BACKLEVEL_OK || this == BACKLEVEL_LIMITED;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIBase.java
// public interface APIBase {
//
// /**
// * internal use only
// */
// APIBase getAPI(int maxVersion);
//
// /**
// * Returns the status of this APi object. See {@link APIStatus} for details.
// */
// APIStatus getStatus();
//
// /**
// * The version number of this API object.
// *
// * This API's contract is that for any version number there is exactly one
// * API interface that will never change.
// *
// * Note: The exception is version 0, which indicates that the object is not
// * a functional API but a placeholder object.
// */
// int getVersion();
// }
| import com.infinityraider.ninjagear.api.APIStatus;
import com.infinityraider.ninjagear.api.APIBase; | package com.infinityraider.ninjagear.api.v0;
/**
* Filler object to represent the API until SettlerCraft had the chance to
* initialize itself.
*
*/
public class NoAPI implements APIBase {
@Override | // Path: src/main/java/com/infinityraider/ninjagear/api/APIStatus.java
// public enum APIStatus {
// /**
// * The API was not properly initialized. Possible reasons:
// *
// * - You called getAPI() before NinjaGear was initialized. Don't call
// * getAPI() in the PREINIT phase.
// *
// * - Someone included the API with their mod, NinjaGear is not actually
// * installed.
// */
// API_NOT_INITIALIZED,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * You still need to check the version of the returned API object, it may be
// * an older version than you expect.
// *
// * Please note that during the init phases not all methods may return final
// * values.
// */
// OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is fully functional.
// */
// BACKLEVEL_OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is basically functional. Some functionality may be missing.
// */
// BACKLEVEL_LIMITED,
// /**
// * No API object for the API version you requested can be supplied.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got a non-functional API object because the
// * requested version is no longer supported.
// */
// BACKLEVEL_UNSUPPORTED,
// /**
// * An error occurred and no API object could be provided.
// *
// * You sill got a non-functional API object.
// */
// ERROR;
//
// /**
// * Shortcut to check for one of the 3 "OK" states that allow you to work
// * with the API object.
// */
// public boolean isOK() {
// return this == OK || this == BACKLEVEL_OK || this == BACKLEVEL_LIMITED;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIBase.java
// public interface APIBase {
//
// /**
// * internal use only
// */
// APIBase getAPI(int maxVersion);
//
// /**
// * Returns the status of this APi object. See {@link APIStatus} for details.
// */
// APIStatus getStatus();
//
// /**
// * The version number of this API object.
// *
// * This API's contract is that for any version number there is exactly one
// * API interface that will never change.
// *
// * Note: The exception is version 0, which indicates that the object is not
// * a functional API but a placeholder object.
// */
// int getVersion();
// }
// Path: src/main/java/com/infinityraider/ninjagear/api/v0/NoAPI.java
import com.infinityraider.ninjagear.api.APIStatus;
import com.infinityraider.ninjagear.api.APIBase;
package com.infinityraider.ninjagear.api.v0;
/**
* Filler object to represent the API until SettlerCraft had the chance to
* initialize itself.
*
*/
public class NoAPI implements APIBase {
@Override | public APIStatus getStatus() { |
InfinityRaider/NinjaGear | src/main/java/com/infinityraider/ninjagear/apiimpl/APISelector.java | // Path: src/main/java/com/infinityraider/ninjagear/api/API.java
// public class API {
// private static APIBase api = new NoAPI();
//
// /**
// * Returns an API object. Call this with the version number of the API you
// * compiled against. It will do its best to return you a matching object.
// *
// * This will never return null, so it is important that you check the
// * APIBase.getStatus() and APIBase.getVersion() before typecasting the
// * result to any specific interface.
// *
// * The API is initialized in SettlerCraft's pre-init phase, don't try to retrieve an API object before this, it will be unusable.
// *
// * @param maxVersion The maximum version allowed to be returned, effectively returned version might be lower
// * @return an APIBase object which interfaces with SettlerCraft
// */
// public static APIBase getAPI(int maxVersion) {
// return api.getAPI(maxVersion);
// }
//
// /**
// * internal use only
// */
// public static void setAPI(APIBase api) {
// API.api = api;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIBase.java
// public interface APIBase {
//
// /**
// * internal use only
// */
// APIBase getAPI(int maxVersion);
//
// /**
// * Returns the status of this APi object. See {@link APIStatus} for details.
// */
// APIStatus getStatus();
//
// /**
// * The version number of this API object.
// *
// * This API's contract is that for any version number there is exactly one
// * API interface that will never change.
// *
// * Note: The exception is version 0, which indicates that the object is not
// * a functional API but a placeholder object.
// */
// int getVersion();
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIStatus.java
// public enum APIStatus {
// /**
// * The API was not properly initialized. Possible reasons:
// *
// * - You called getAPI() before NinjaGear was initialized. Don't call
// * getAPI() in the PREINIT phase.
// *
// * - Someone included the API with their mod, NinjaGear is not actually
// * installed.
// */
// API_NOT_INITIALIZED,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * You still need to check the version of the returned API object, it may be
// * an older version than you expect.
// *
// * Please note that during the init phases not all methods may return final
// * values.
// */
// OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is fully functional.
// */
// BACKLEVEL_OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is basically functional. Some functionality may be missing.
// */
// BACKLEVEL_LIMITED,
// /**
// * No API object for the API version you requested can be supplied.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got a non-functional API object because the
// * requested version is no longer supported.
// */
// BACKLEVEL_UNSUPPORTED,
// /**
// * An error occurred and no API object could be provided.
// *
// * You sill got a non-functional API object.
// */
// ERROR;
//
// /**
// * Shortcut to check for one of the 3 "OK" states that allow you to work
// * with the API object.
// */
// public boolean isOK() {
// return this == OK || this == BACKLEVEL_OK || this == BACKLEVEL_LIMITED;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/apiimpl/v1/APIimplv1.java
// public class APIimplv1 implements APIv1 {
// private final int version;
// private final APIStatus status;
//
// public APIimplv1(int version, APIStatus status) {
// this.version = version;
// this.status = status;
// }
//
// @Override
// public APIBase getAPI(int maxVersion) {
// if (maxVersion == version && status == APIStatus.OK) {
// return this;
// } else {
// return API.getAPI(maxVersion);
// }
// }
//
// @Override
// public APIStatus getStatus() {
// return status;
// }
//
// @Override
// public int getVersion() {
// return version;
// }
// @Override
// public boolean isPlayerHidden(PlayerEntity player) {
// return NinjaGear.instance.proxy().isPlayerHidden(player);
// }
//
// @Override
// public void revealPlayer(PlayerEntity player, int duration, boolean breakSmoke) {
// NinjaAuraHandler.getInstance().revealEntity(player, duration, breakSmoke);
// }
// }
| import com.infinityraider.ninjagear.api.API;
import com.infinityraider.ninjagear.api.APIBase;
import com.infinityraider.ninjagear.api.APIStatus;
import com.infinityraider.ninjagear.apiimpl.v1.APIimplv1; | package com.infinityraider.ninjagear.apiimpl;
public class APISelector implements APIBase {
private APISelector() {}
public static void init() { | // Path: src/main/java/com/infinityraider/ninjagear/api/API.java
// public class API {
// private static APIBase api = new NoAPI();
//
// /**
// * Returns an API object. Call this with the version number of the API you
// * compiled against. It will do its best to return you a matching object.
// *
// * This will never return null, so it is important that you check the
// * APIBase.getStatus() and APIBase.getVersion() before typecasting the
// * result to any specific interface.
// *
// * The API is initialized in SettlerCraft's pre-init phase, don't try to retrieve an API object before this, it will be unusable.
// *
// * @param maxVersion The maximum version allowed to be returned, effectively returned version might be lower
// * @return an APIBase object which interfaces with SettlerCraft
// */
// public static APIBase getAPI(int maxVersion) {
// return api.getAPI(maxVersion);
// }
//
// /**
// * internal use only
// */
// public static void setAPI(APIBase api) {
// API.api = api;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIBase.java
// public interface APIBase {
//
// /**
// * internal use only
// */
// APIBase getAPI(int maxVersion);
//
// /**
// * Returns the status of this APi object. See {@link APIStatus} for details.
// */
// APIStatus getStatus();
//
// /**
// * The version number of this API object.
// *
// * This API's contract is that for any version number there is exactly one
// * API interface that will never change.
// *
// * Note: The exception is version 0, which indicates that the object is not
// * a functional API but a placeholder object.
// */
// int getVersion();
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIStatus.java
// public enum APIStatus {
// /**
// * The API was not properly initialized. Possible reasons:
// *
// * - You called getAPI() before NinjaGear was initialized. Don't call
// * getAPI() in the PREINIT phase.
// *
// * - Someone included the API with their mod, NinjaGear is not actually
// * installed.
// */
// API_NOT_INITIALIZED,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * You still need to check the version of the returned API object, it may be
// * an older version than you expect.
// *
// * Please note that during the init phases not all methods may return final
// * values.
// */
// OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is fully functional.
// */
// BACKLEVEL_OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is basically functional. Some functionality may be missing.
// */
// BACKLEVEL_LIMITED,
// /**
// * No API object for the API version you requested can be supplied.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got a non-functional API object because the
// * requested version is no longer supported.
// */
// BACKLEVEL_UNSUPPORTED,
// /**
// * An error occurred and no API object could be provided.
// *
// * You sill got a non-functional API object.
// */
// ERROR;
//
// /**
// * Shortcut to check for one of the 3 "OK" states that allow you to work
// * with the API object.
// */
// public boolean isOK() {
// return this == OK || this == BACKLEVEL_OK || this == BACKLEVEL_LIMITED;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/apiimpl/v1/APIimplv1.java
// public class APIimplv1 implements APIv1 {
// private final int version;
// private final APIStatus status;
//
// public APIimplv1(int version, APIStatus status) {
// this.version = version;
// this.status = status;
// }
//
// @Override
// public APIBase getAPI(int maxVersion) {
// if (maxVersion == version && status == APIStatus.OK) {
// return this;
// } else {
// return API.getAPI(maxVersion);
// }
// }
//
// @Override
// public APIStatus getStatus() {
// return status;
// }
//
// @Override
// public int getVersion() {
// return version;
// }
// @Override
// public boolean isPlayerHidden(PlayerEntity player) {
// return NinjaGear.instance.proxy().isPlayerHidden(player);
// }
//
// @Override
// public void revealPlayer(PlayerEntity player, int duration, boolean breakSmoke) {
// NinjaAuraHandler.getInstance().revealEntity(player, duration, breakSmoke);
// }
// }
// Path: src/main/java/com/infinityraider/ninjagear/apiimpl/APISelector.java
import com.infinityraider.ninjagear.api.API;
import com.infinityraider.ninjagear.api.APIBase;
import com.infinityraider.ninjagear.api.APIStatus;
import com.infinityraider.ninjagear.apiimpl.v1.APIimplv1;
package com.infinityraider.ninjagear.apiimpl;
public class APISelector implements APIBase {
private APISelector() {}
public static void init() { | API.setAPI(new APISelector()); |
InfinityRaider/NinjaGear | src/main/java/com/infinityraider/ninjagear/apiimpl/APISelector.java | // Path: src/main/java/com/infinityraider/ninjagear/api/API.java
// public class API {
// private static APIBase api = new NoAPI();
//
// /**
// * Returns an API object. Call this with the version number of the API you
// * compiled against. It will do its best to return you a matching object.
// *
// * This will never return null, so it is important that you check the
// * APIBase.getStatus() and APIBase.getVersion() before typecasting the
// * result to any specific interface.
// *
// * The API is initialized in SettlerCraft's pre-init phase, don't try to retrieve an API object before this, it will be unusable.
// *
// * @param maxVersion The maximum version allowed to be returned, effectively returned version might be lower
// * @return an APIBase object which interfaces with SettlerCraft
// */
// public static APIBase getAPI(int maxVersion) {
// return api.getAPI(maxVersion);
// }
//
// /**
// * internal use only
// */
// public static void setAPI(APIBase api) {
// API.api = api;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIBase.java
// public interface APIBase {
//
// /**
// * internal use only
// */
// APIBase getAPI(int maxVersion);
//
// /**
// * Returns the status of this APi object. See {@link APIStatus} for details.
// */
// APIStatus getStatus();
//
// /**
// * The version number of this API object.
// *
// * This API's contract is that for any version number there is exactly one
// * API interface that will never change.
// *
// * Note: The exception is version 0, which indicates that the object is not
// * a functional API but a placeholder object.
// */
// int getVersion();
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIStatus.java
// public enum APIStatus {
// /**
// * The API was not properly initialized. Possible reasons:
// *
// * - You called getAPI() before NinjaGear was initialized. Don't call
// * getAPI() in the PREINIT phase.
// *
// * - Someone included the API with their mod, NinjaGear is not actually
// * installed.
// */
// API_NOT_INITIALIZED,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * You still need to check the version of the returned API object, it may be
// * an older version than you expect.
// *
// * Please note that during the init phases not all methods may return final
// * values.
// */
// OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is fully functional.
// */
// BACKLEVEL_OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is basically functional. Some functionality may be missing.
// */
// BACKLEVEL_LIMITED,
// /**
// * No API object for the API version you requested can be supplied.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got a non-functional API object because the
// * requested version is no longer supported.
// */
// BACKLEVEL_UNSUPPORTED,
// /**
// * An error occurred and no API object could be provided.
// *
// * You sill got a non-functional API object.
// */
// ERROR;
//
// /**
// * Shortcut to check for one of the 3 "OK" states that allow you to work
// * with the API object.
// */
// public boolean isOK() {
// return this == OK || this == BACKLEVEL_OK || this == BACKLEVEL_LIMITED;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/apiimpl/v1/APIimplv1.java
// public class APIimplv1 implements APIv1 {
// private final int version;
// private final APIStatus status;
//
// public APIimplv1(int version, APIStatus status) {
// this.version = version;
// this.status = status;
// }
//
// @Override
// public APIBase getAPI(int maxVersion) {
// if (maxVersion == version && status == APIStatus.OK) {
// return this;
// } else {
// return API.getAPI(maxVersion);
// }
// }
//
// @Override
// public APIStatus getStatus() {
// return status;
// }
//
// @Override
// public int getVersion() {
// return version;
// }
// @Override
// public boolean isPlayerHidden(PlayerEntity player) {
// return NinjaGear.instance.proxy().isPlayerHidden(player);
// }
//
// @Override
// public void revealPlayer(PlayerEntity player, int duration, boolean breakSmoke) {
// NinjaAuraHandler.getInstance().revealEntity(player, duration, breakSmoke);
// }
// }
| import com.infinityraider.ninjagear.api.API;
import com.infinityraider.ninjagear.api.APIBase;
import com.infinityraider.ninjagear.api.APIStatus;
import com.infinityraider.ninjagear.apiimpl.v1.APIimplv1; | package com.infinityraider.ninjagear.apiimpl;
public class APISelector implements APIBase {
private APISelector() {}
public static void init() {
API.setAPI(new APISelector());
}
@Override
public APIBase getAPI(int maxVersion) {
if (maxVersion <= 0) {
return this;
} else {
switch(maxVersion) {
case 1: | // Path: src/main/java/com/infinityraider/ninjagear/api/API.java
// public class API {
// private static APIBase api = new NoAPI();
//
// /**
// * Returns an API object. Call this with the version number of the API you
// * compiled against. It will do its best to return you a matching object.
// *
// * This will never return null, so it is important that you check the
// * APIBase.getStatus() and APIBase.getVersion() before typecasting the
// * result to any specific interface.
// *
// * The API is initialized in SettlerCraft's pre-init phase, don't try to retrieve an API object before this, it will be unusable.
// *
// * @param maxVersion The maximum version allowed to be returned, effectively returned version might be lower
// * @return an APIBase object which interfaces with SettlerCraft
// */
// public static APIBase getAPI(int maxVersion) {
// return api.getAPI(maxVersion);
// }
//
// /**
// * internal use only
// */
// public static void setAPI(APIBase api) {
// API.api = api;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIBase.java
// public interface APIBase {
//
// /**
// * internal use only
// */
// APIBase getAPI(int maxVersion);
//
// /**
// * Returns the status of this APi object. See {@link APIStatus} for details.
// */
// APIStatus getStatus();
//
// /**
// * The version number of this API object.
// *
// * This API's contract is that for any version number there is exactly one
// * API interface that will never change.
// *
// * Note: The exception is version 0, which indicates that the object is not
// * a functional API but a placeholder object.
// */
// int getVersion();
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIStatus.java
// public enum APIStatus {
// /**
// * The API was not properly initialized. Possible reasons:
// *
// * - You called getAPI() before NinjaGear was initialized. Don't call
// * getAPI() in the PREINIT phase.
// *
// * - Someone included the API with their mod, NinjaGear is not actually
// * installed.
// */
// API_NOT_INITIALIZED,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * You still need to check the version of the returned API object, it may be
// * an older version than you expect.
// *
// * Please note that during the init phases not all methods may return final
// * values.
// */
// OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is fully functional.
// */
// BACKLEVEL_OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is basically functional. Some functionality may be missing.
// */
// BACKLEVEL_LIMITED,
// /**
// * No API object for the API version you requested can be supplied.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got a non-functional API object because the
// * requested version is no longer supported.
// */
// BACKLEVEL_UNSUPPORTED,
// /**
// * An error occurred and no API object could be provided.
// *
// * You sill got a non-functional API object.
// */
// ERROR;
//
// /**
// * Shortcut to check for one of the 3 "OK" states that allow you to work
// * with the API object.
// */
// public boolean isOK() {
// return this == OK || this == BACKLEVEL_OK || this == BACKLEVEL_LIMITED;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/apiimpl/v1/APIimplv1.java
// public class APIimplv1 implements APIv1 {
// private final int version;
// private final APIStatus status;
//
// public APIimplv1(int version, APIStatus status) {
// this.version = version;
// this.status = status;
// }
//
// @Override
// public APIBase getAPI(int maxVersion) {
// if (maxVersion == version && status == APIStatus.OK) {
// return this;
// } else {
// return API.getAPI(maxVersion);
// }
// }
//
// @Override
// public APIStatus getStatus() {
// return status;
// }
//
// @Override
// public int getVersion() {
// return version;
// }
// @Override
// public boolean isPlayerHidden(PlayerEntity player) {
// return NinjaGear.instance.proxy().isPlayerHidden(player);
// }
//
// @Override
// public void revealPlayer(PlayerEntity player, int duration, boolean breakSmoke) {
// NinjaAuraHandler.getInstance().revealEntity(player, duration, breakSmoke);
// }
// }
// Path: src/main/java/com/infinityraider/ninjagear/apiimpl/APISelector.java
import com.infinityraider.ninjagear.api.API;
import com.infinityraider.ninjagear.api.APIBase;
import com.infinityraider.ninjagear.api.APIStatus;
import com.infinityraider.ninjagear.apiimpl.v1.APIimplv1;
package com.infinityraider.ninjagear.apiimpl;
public class APISelector implements APIBase {
private APISelector() {}
public static void init() {
API.setAPI(new APISelector());
}
@Override
public APIBase getAPI(int maxVersion) {
if (maxVersion <= 0) {
return this;
} else {
switch(maxVersion) {
case 1: | return new APIimplv1(1, APIStatus.OK); |
InfinityRaider/NinjaGear | src/main/java/com/infinityraider/ninjagear/apiimpl/APISelector.java | // Path: src/main/java/com/infinityraider/ninjagear/api/API.java
// public class API {
// private static APIBase api = new NoAPI();
//
// /**
// * Returns an API object. Call this with the version number of the API you
// * compiled against. It will do its best to return you a matching object.
// *
// * This will never return null, so it is important that you check the
// * APIBase.getStatus() and APIBase.getVersion() before typecasting the
// * result to any specific interface.
// *
// * The API is initialized in SettlerCraft's pre-init phase, don't try to retrieve an API object before this, it will be unusable.
// *
// * @param maxVersion The maximum version allowed to be returned, effectively returned version might be lower
// * @return an APIBase object which interfaces with SettlerCraft
// */
// public static APIBase getAPI(int maxVersion) {
// return api.getAPI(maxVersion);
// }
//
// /**
// * internal use only
// */
// public static void setAPI(APIBase api) {
// API.api = api;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIBase.java
// public interface APIBase {
//
// /**
// * internal use only
// */
// APIBase getAPI(int maxVersion);
//
// /**
// * Returns the status of this APi object. See {@link APIStatus} for details.
// */
// APIStatus getStatus();
//
// /**
// * The version number of this API object.
// *
// * This API's contract is that for any version number there is exactly one
// * API interface that will never change.
// *
// * Note: The exception is version 0, which indicates that the object is not
// * a functional API but a placeholder object.
// */
// int getVersion();
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIStatus.java
// public enum APIStatus {
// /**
// * The API was not properly initialized. Possible reasons:
// *
// * - You called getAPI() before NinjaGear was initialized. Don't call
// * getAPI() in the PREINIT phase.
// *
// * - Someone included the API with their mod, NinjaGear is not actually
// * installed.
// */
// API_NOT_INITIALIZED,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * You still need to check the version of the returned API object, it may be
// * an older version than you expect.
// *
// * Please note that during the init phases not all methods may return final
// * values.
// */
// OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is fully functional.
// */
// BACKLEVEL_OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is basically functional. Some functionality may be missing.
// */
// BACKLEVEL_LIMITED,
// /**
// * No API object for the API version you requested can be supplied.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got a non-functional API object because the
// * requested version is no longer supported.
// */
// BACKLEVEL_UNSUPPORTED,
// /**
// * An error occurred and no API object could be provided.
// *
// * You sill got a non-functional API object.
// */
// ERROR;
//
// /**
// * Shortcut to check for one of the 3 "OK" states that allow you to work
// * with the API object.
// */
// public boolean isOK() {
// return this == OK || this == BACKLEVEL_OK || this == BACKLEVEL_LIMITED;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/apiimpl/v1/APIimplv1.java
// public class APIimplv1 implements APIv1 {
// private final int version;
// private final APIStatus status;
//
// public APIimplv1(int version, APIStatus status) {
// this.version = version;
// this.status = status;
// }
//
// @Override
// public APIBase getAPI(int maxVersion) {
// if (maxVersion == version && status == APIStatus.OK) {
// return this;
// } else {
// return API.getAPI(maxVersion);
// }
// }
//
// @Override
// public APIStatus getStatus() {
// return status;
// }
//
// @Override
// public int getVersion() {
// return version;
// }
// @Override
// public boolean isPlayerHidden(PlayerEntity player) {
// return NinjaGear.instance.proxy().isPlayerHidden(player);
// }
//
// @Override
// public void revealPlayer(PlayerEntity player, int duration, boolean breakSmoke) {
// NinjaAuraHandler.getInstance().revealEntity(player, duration, breakSmoke);
// }
// }
| import com.infinityraider.ninjagear.api.API;
import com.infinityraider.ninjagear.api.APIBase;
import com.infinityraider.ninjagear.api.APIStatus;
import com.infinityraider.ninjagear.apiimpl.v1.APIimplv1; | package com.infinityraider.ninjagear.apiimpl;
public class APISelector implements APIBase {
private APISelector() {}
public static void init() {
API.setAPI(new APISelector());
}
@Override
public APIBase getAPI(int maxVersion) {
if (maxVersion <= 0) {
return this;
} else {
switch(maxVersion) {
case 1: | // Path: src/main/java/com/infinityraider/ninjagear/api/API.java
// public class API {
// private static APIBase api = new NoAPI();
//
// /**
// * Returns an API object. Call this with the version number of the API you
// * compiled against. It will do its best to return you a matching object.
// *
// * This will never return null, so it is important that you check the
// * APIBase.getStatus() and APIBase.getVersion() before typecasting the
// * result to any specific interface.
// *
// * The API is initialized in SettlerCraft's pre-init phase, don't try to retrieve an API object before this, it will be unusable.
// *
// * @param maxVersion The maximum version allowed to be returned, effectively returned version might be lower
// * @return an APIBase object which interfaces with SettlerCraft
// */
// public static APIBase getAPI(int maxVersion) {
// return api.getAPI(maxVersion);
// }
//
// /**
// * internal use only
// */
// public static void setAPI(APIBase api) {
// API.api = api;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIBase.java
// public interface APIBase {
//
// /**
// * internal use only
// */
// APIBase getAPI(int maxVersion);
//
// /**
// * Returns the status of this APi object. See {@link APIStatus} for details.
// */
// APIStatus getStatus();
//
// /**
// * The version number of this API object.
// *
// * This API's contract is that for any version number there is exactly one
// * API interface that will never change.
// *
// * Note: The exception is version 0, which indicates that the object is not
// * a functional API but a placeholder object.
// */
// int getVersion();
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/api/APIStatus.java
// public enum APIStatus {
// /**
// * The API was not properly initialized. Possible reasons:
// *
// * - You called getAPI() before NinjaGear was initialized. Don't call
// * getAPI() in the PREINIT phase.
// *
// * - Someone included the API with their mod, NinjaGear is not actually
// * installed.
// */
// API_NOT_INITIALIZED,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * You still need to check the version of the returned API object, it may be
// * an older version than you expect.
// *
// * Please note that during the init phases not all methods may return final
// * values.
// */
// OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is fully functional.
// */
// BACKLEVEL_OK,
// /**
// * The API was properly loaded and your API object is ready to go.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got an API object of the requested version and
// * it is basically functional. Some functionality may be missing.
// */
// BACKLEVEL_LIMITED,
// /**
// * No API object for the API version you requested can be supplied.
// *
// * The NinjaGear that returned your API object supports a newer version than
// * the one you requested. You got a non-functional API object because the
// * requested version is no longer supported.
// */
// BACKLEVEL_UNSUPPORTED,
// /**
// * An error occurred and no API object could be provided.
// *
// * You sill got a non-functional API object.
// */
// ERROR;
//
// /**
// * Shortcut to check for one of the 3 "OK" states that allow you to work
// * with the API object.
// */
// public boolean isOK() {
// return this == OK || this == BACKLEVEL_OK || this == BACKLEVEL_LIMITED;
// }
// }
//
// Path: src/main/java/com/infinityraider/ninjagear/apiimpl/v1/APIimplv1.java
// public class APIimplv1 implements APIv1 {
// private final int version;
// private final APIStatus status;
//
// public APIimplv1(int version, APIStatus status) {
// this.version = version;
// this.status = status;
// }
//
// @Override
// public APIBase getAPI(int maxVersion) {
// if (maxVersion == version && status == APIStatus.OK) {
// return this;
// } else {
// return API.getAPI(maxVersion);
// }
// }
//
// @Override
// public APIStatus getStatus() {
// return status;
// }
//
// @Override
// public int getVersion() {
// return version;
// }
// @Override
// public boolean isPlayerHidden(PlayerEntity player) {
// return NinjaGear.instance.proxy().isPlayerHidden(player);
// }
//
// @Override
// public void revealPlayer(PlayerEntity player, int duration, boolean breakSmoke) {
// NinjaAuraHandler.getInstance().revealEntity(player, duration, breakSmoke);
// }
// }
// Path: src/main/java/com/infinityraider/ninjagear/apiimpl/APISelector.java
import com.infinityraider.ninjagear.api.API;
import com.infinityraider.ninjagear.api.APIBase;
import com.infinityraider.ninjagear.api.APIStatus;
import com.infinityraider.ninjagear.apiimpl.v1.APIimplv1;
package com.infinityraider.ninjagear.apiimpl;
public class APISelector implements APIBase {
private APISelector() {}
public static void init() {
API.setAPI(new APISelector());
}
@Override
public APIBase getAPI(int maxVersion) {
if (maxVersion <= 0) {
return this;
} else {
switch(maxVersion) {
case 1: | return new APIimplv1(1, APIStatus.OK); |
InfinityRaider/NinjaGear | src/main/java/com/infinityraider/ninjagear/network/MessageInvisibility.java | // Path: src/main/java/com/infinityraider/ninjagear/handler/RenderPlayerHandler.java
// @OnlyIn(Dist.CLIENT)
// public class RenderPlayerHandler {
// private static final RenderPlayerHandler INSTANCE = new RenderPlayerHandler();
//
// public static RenderPlayerHandler getInstance() {
// return INSTANCE;
// }
//
// private final HashMap<UUID, Boolean> invisibilityMap;
//
// private RenderPlayerHandler() {
// this.invisibilityMap = new HashMap<>();
// }
//
// public void setPlayerInvisibilityStatus(PlayerEntity player, boolean invisible) {
// invisibilityMap.put(player.getUniqueID(), invisible);
// }
//
// public boolean isInvisible(PlayerEntity player) {
// if(player == Minecraft.getInstance().player) {
// return player.isPotionActive(EffectRegistry.getInstance().effectNinjaHidden);
// }
// return invisibilityMap.containsKey(player.getUniqueID()) && invisibilityMap.get(player.getUniqueID());
// }
//
// @SubscribeEvent
// @SuppressWarnings("unused")
// public void onRenderLivingEvent(RenderLivingEvent.Pre<?,?> event) {
// LivingEntity entity = event.getEntity();
// if((entity instanceof PlayerEntity) && isInvisible((PlayerEntity) entity)) {
// event.setCanceled(true);
// event.setResult(Event.Result.DENY);
// }
// }
//
// @SubscribeEvent
// @SuppressWarnings("unused")
// public void onRenderLivingEvent(RenderPlayerEvent.Pre event) {
// PlayerEntity entity = event.getPlayer();
// if(isInvisible(entity)) {
// event.setCanceled(true);
// event.setResult(Event.Result.DENY);
// }
// }
// }
| import com.infinityraider.infinitylib.network.MessageBase;
import com.infinityraider.ninjagear.handler.RenderPlayerHandler;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.fml.network.NetworkDirection;
import net.minecraftforge.fml.network.NetworkEvent; | package com.infinityraider.ninjagear.network;
public class MessageInvisibility extends MessageBase {
private PlayerEntity player;
private boolean invisible;
public MessageInvisibility() {
super();
}
public MessageInvisibility(PlayerEntity player, boolean invisible) {
this();
this.player = player;
this.invisible = invisible;
}
@Override
public NetworkDirection getMessageDirection() {
return NetworkDirection.PLAY_TO_CLIENT;
}
@Override
protected void processMessage(NetworkEvent.Context ctx) {
if(this.player != null) { | // Path: src/main/java/com/infinityraider/ninjagear/handler/RenderPlayerHandler.java
// @OnlyIn(Dist.CLIENT)
// public class RenderPlayerHandler {
// private static final RenderPlayerHandler INSTANCE = new RenderPlayerHandler();
//
// public static RenderPlayerHandler getInstance() {
// return INSTANCE;
// }
//
// private final HashMap<UUID, Boolean> invisibilityMap;
//
// private RenderPlayerHandler() {
// this.invisibilityMap = new HashMap<>();
// }
//
// public void setPlayerInvisibilityStatus(PlayerEntity player, boolean invisible) {
// invisibilityMap.put(player.getUniqueID(), invisible);
// }
//
// public boolean isInvisible(PlayerEntity player) {
// if(player == Minecraft.getInstance().player) {
// return player.isPotionActive(EffectRegistry.getInstance().effectNinjaHidden);
// }
// return invisibilityMap.containsKey(player.getUniqueID()) && invisibilityMap.get(player.getUniqueID());
// }
//
// @SubscribeEvent
// @SuppressWarnings("unused")
// public void onRenderLivingEvent(RenderLivingEvent.Pre<?,?> event) {
// LivingEntity entity = event.getEntity();
// if((entity instanceof PlayerEntity) && isInvisible((PlayerEntity) entity)) {
// event.setCanceled(true);
// event.setResult(Event.Result.DENY);
// }
// }
//
// @SubscribeEvent
// @SuppressWarnings("unused")
// public void onRenderLivingEvent(RenderPlayerEvent.Pre event) {
// PlayerEntity entity = event.getPlayer();
// if(isInvisible(entity)) {
// event.setCanceled(true);
// event.setResult(Event.Result.DENY);
// }
// }
// }
// Path: src/main/java/com/infinityraider/ninjagear/network/MessageInvisibility.java
import com.infinityraider.infinitylib.network.MessageBase;
import com.infinityraider.ninjagear.handler.RenderPlayerHandler;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.fml.network.NetworkDirection;
import net.minecraftforge.fml.network.NetworkEvent;
package com.infinityraider.ninjagear.network;
public class MessageInvisibility extends MessageBase {
private PlayerEntity player;
private boolean invisible;
public MessageInvisibility() {
super();
}
public MessageInvisibility(PlayerEntity player, boolean invisible) {
this();
this.player = player;
this.invisible = invisible;
}
@Override
public NetworkDirection getMessageDirection() {
return NetworkDirection.PLAY_TO_CLIENT;
}
@Override
protected void processMessage(NetworkEvent.Context ctx) {
if(this.player != null) { | RenderPlayerHandler.getInstance().setPlayerInvisibilityStatus(this.player, this.invisible); |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/UnaryOperation/VoidOp.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.UnaryOperation;
public class VoidOp extends UnaryOperation {
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/UnaryOperation/VoidOp.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.UnaryOperation;
public class VoidOp extends UnaryOperation {
@Nonnull | public final NodeWithValue expression; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/ExplicatorWithLocation.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Halt.java
// public class Halt implements NodeWithValue {
// @Nonnull
// public static final Halt INSTANCE = new Halt();
//
//
// private Halt() {
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.functional.F;
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.ast.Directive;
import com.shapesecurity.shift.es2017.ast.FunctionBody;
import com.shapesecurity.shift.es2017.ast.Script;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.Halt;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.WeakHashMap;
import java.util.function.Supplier; | package com.shapesecurity.shift.es2017.semantics;
public class ExplicatorWithLocation {
private static class Implementation extends Explicator {
@NotNull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Halt.java
// public class Halt implements NodeWithValue {
// @Nonnull
// public static final Halt INSTANCE = new Halt();
//
//
// private Halt() {
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/ExplicatorWithLocation.java
import com.shapesecurity.functional.F;
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.ast.Directive;
import com.shapesecurity.shift.es2017.ast.FunctionBody;
import com.shapesecurity.shift.es2017.ast.Script;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.Halt;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.WeakHashMap;
import java.util.function.Supplier;
package com.shapesecurity.shift.es2017.semantics;
public class ExplicatorWithLocation {
private static class Implementation extends Explicator {
@NotNull | final WeakHashMap<LiteralFunction, FunctionBody> locations = new WeakHashMap<>(); |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/ExplicatorWithLocation.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Halt.java
// public class Halt implements NodeWithValue {
// @Nonnull
// public static final Halt INSTANCE = new Halt();
//
//
// private Halt() {
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.functional.F;
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.ast.Directive;
import com.shapesecurity.shift.es2017.ast.FunctionBody;
import com.shapesecurity.shift.es2017.ast.Script;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.Halt;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.WeakHashMap;
import java.util.function.Supplier; | package com.shapesecurity.shift.es2017.semantics;
public class ExplicatorWithLocation {
private static class Implementation extends Explicator {
@NotNull
final WeakHashMap<LiteralFunction, FunctionBody> locations = new WeakHashMap<>();
Implementation(@Nonnull Script script) { | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Halt.java
// public class Halt implements NodeWithValue {
// @Nonnull
// public static final Halt INSTANCE = new Halt();
//
//
// private Halt() {
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/ExplicatorWithLocation.java
import com.shapesecurity.functional.F;
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.ast.Directive;
import com.shapesecurity.shift.es2017.ast.FunctionBody;
import com.shapesecurity.shift.es2017.ast.Script;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.Halt;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.WeakHashMap;
import java.util.function.Supplier;
package com.shapesecurity.shift.es2017.semantics;
public class ExplicatorWithLocation {
private static class Implementation extends Explicator {
@NotNull
final WeakHashMap<LiteralFunction, FunctionBody> locations = new WeakHashMap<>();
Implementation(@Nonnull Script script) { | super(script, list -> false, () -> Halt.INSTANCE); |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/ExplicatorWithLocation.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Halt.java
// public class Halt implements NodeWithValue {
// @Nonnull
// public static final Halt INSTANCE = new Halt();
//
//
// private Halt() {
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.functional.F;
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.ast.Directive;
import com.shapesecurity.shift.es2017.ast.FunctionBody;
import com.shapesecurity.shift.es2017.ast.Script;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.Halt;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.WeakHashMap;
import java.util.function.Supplier; | package com.shapesecurity.shift.es2017.semantics;
public class ExplicatorWithLocation {
private static class Implementation extends Explicator {
@NotNull
final WeakHashMap<LiteralFunction, FunctionBody> locations = new WeakHashMap<>();
Implementation(@Nonnull Script script) {
super(script, list -> false, () -> Halt.INSTANCE);
}
| // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Halt.java
// public class Halt implements NodeWithValue {
// @Nonnull
// public static final Halt INSTANCE = new Halt();
//
//
// private Halt() {
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/ExplicatorWithLocation.java
import com.shapesecurity.functional.F;
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.ast.Directive;
import com.shapesecurity.shift.es2017.ast.FunctionBody;
import com.shapesecurity.shift.es2017.ast.Script;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.Halt;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.WeakHashMap;
import java.util.function.Supplier;
package com.shapesecurity.shift.es2017.semantics;
public class ExplicatorWithLocation {
private static class Implementation extends Explicator {
@NotNull
final WeakHashMap<LiteralFunction, FunctionBody> locations = new WeakHashMap<>();
Implementation(@Nonnull Script script) {
super(script, list -> false, () -> Halt.INSTANCE);
}
| Implementation(@Nonnull Script script, @Nonnull F<ImmutableList<Directive>, Boolean> isCandidateForInlining, Supplier<NodeWithValue> getDirectEval) { |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/ExplicatorWithLocation.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Halt.java
// public class Halt implements NodeWithValue {
// @Nonnull
// public static final Halt INSTANCE = new Halt();
//
//
// private Halt() {
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.functional.F;
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.ast.Directive;
import com.shapesecurity.shift.es2017.ast.FunctionBody;
import com.shapesecurity.shift.es2017.ast.Script;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.Halt;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.WeakHashMap;
import java.util.function.Supplier; | }
Implementation(@Nonnull Script script, @Nonnull F<ImmutableList<Directive>, Boolean> isCandidateForInlining, Supplier<NodeWithValue> getDirectEval) {
super(script, isCandidateForInlining, getDirectEval);
}
@Override
@Nonnull
LiteralFunction explicateGeneralFunction(
@Nonnull Maybe<Variable> name, @Nonnull Scope scope, @Nonnull ImmutableList<Variable> parameters,
@Nonnull FunctionBody functionBody, boolean strict
) {
LiteralFunction result = super.explicateGeneralFunction(name, scope, parameters, functionBody, strict);
this.locations.put(result, functionBody);
return result;
}
}
@Nonnull
public static Pair<Semantics, WeakHashMap<LiteralFunction, FunctionBody>> deriveSemanticsWithLocation(@Nonnull Script script) {
return deriveSemanticsWithLocationHelper(script, new Implementation(script));
}
@Nonnull
public static Pair<Semantics, WeakHashMap<LiteralFunction, FunctionBody>> deriveSemanticsWithLocation(@Nonnull Script script, @Nonnull F<ImmutableList<Directive>, Boolean> isCandidateForInlining, Supplier<NodeWithValue> getDirectEval) {
return deriveSemanticsWithLocationHelper(script, new Implementation(script, isCandidateForInlining, getDirectEval));
}
@Nonnull
private static Pair<Semantics, WeakHashMap<LiteralFunction, FunctionBody>> deriveSemanticsWithLocationHelper(@Nonnull Script script, @Nonnull Implementation exp) { | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Halt.java
// public class Halt implements NodeWithValue {
// @Nonnull
// public static final Halt INSTANCE = new Halt();
//
//
// private Halt() {
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/ExplicatorWithLocation.java
import com.shapesecurity.functional.F;
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.ast.Directive;
import com.shapesecurity.shift.es2017.ast.FunctionBody;
import com.shapesecurity.shift.es2017.ast.Script;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.Halt;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.util.WeakHashMap;
import java.util.function.Supplier;
}
Implementation(@Nonnull Script script, @Nonnull F<ImmutableList<Directive>, Boolean> isCandidateForInlining, Supplier<NodeWithValue> getDirectEval) {
super(script, isCandidateForInlining, getDirectEval);
}
@Override
@Nonnull
LiteralFunction explicateGeneralFunction(
@Nonnull Maybe<Variable> name, @Nonnull Scope scope, @Nonnull ImmutableList<Variable> parameters,
@Nonnull FunctionBody functionBody, boolean strict
) {
LiteralFunction result = super.explicateGeneralFunction(name, scope, parameters, functionBody, strict);
this.locations.put(result, functionBody);
return result;
}
}
@Nonnull
public static Pair<Semantics, WeakHashMap<LiteralFunction, FunctionBody>> deriveSemanticsWithLocation(@Nonnull Script script) {
return deriveSemanticsWithLocationHelper(script, new Implementation(script));
}
@Nonnull
public static Pair<Semantics, WeakHashMap<LiteralFunction, FunctionBody>> deriveSemanticsWithLocation(@Nonnull Script script, @Nonnull F<ImmutableList<Directive>, Boolean> isCandidateForInlining, Supplier<NodeWithValue> getDirectEval) {
return deriveSemanticsWithLocationHelper(script, new Implementation(script, isCandidateForInlining, getDirectEval));
}
@Nonnull
private static Pair<Semantics, WeakHashMap<LiteralFunction, FunctionBody>> deriveSemanticsWithLocationHelper(@Nonnull Script script, @Nonnull Implementation exp) { | Node result = exp.explicate(); |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/In.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class In extends BinaryOperation {
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/In.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class In extends BinaryOperation {
@Nonnull | public final NodeWithValue left; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/FloatMath.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class FloatMath extends BinaryOperation {
@Nonnull
public final Operator operator;
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/FloatMath.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class FloatMath extends BinaryOperation {
@Nonnull
public final Operator operator;
@Nonnull | public final NodeWithValue left; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/PerFunctionState.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BreakTarget.java
// public class BreakTarget implements Node { // no-op. target of a break.
//
// public BreakTarget() {
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node == this;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LocalReference.java
// public class LocalReference implements NodeWithValue {
// @Nonnull
// public Variable variable;
//
//
// public LocalReference(@Nonnull Variable variable) {
// this.variable = variable;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == LocalReference.class && this.variable.equals(((LocalReference) node).variable);
// }
// }
| import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.BreakTarget;
import com.shapesecurity.shift.es2017.semantics.asg.LocalReference; | package com.shapesecurity.shift.es2017.semantics;
public class PerFunctionState {
private ImmutableList<Variable> additionalVariables;
private ImmutableList<InlineFunctionState> inlineFunctionStates;
public PerFunctionState() {
additionalVariables = ImmutableList.empty();
inlineFunctionStates = ImmutableList.empty();
}
public void addVariable(Variable variable) {
additionalVariables = additionalVariables.cons(variable);
}
public ImmutableList<Variable> getAdditionalVariables() {
return additionalVariables;
}
| // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BreakTarget.java
// public class BreakTarget implements Node { // no-op. target of a break.
//
// public BreakTarget() {
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node == this;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LocalReference.java
// public class LocalReference implements NodeWithValue {
// @Nonnull
// public Variable variable;
//
//
// public LocalReference(@Nonnull Variable variable) {
// this.variable = variable;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == LocalReference.class && this.variable.equals(((LocalReference) node).variable);
// }
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/PerFunctionState.java
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.BreakTarget;
import com.shapesecurity.shift.es2017.semantics.asg.LocalReference;
package com.shapesecurity.shift.es2017.semantics;
public class PerFunctionState {
private ImmutableList<Variable> additionalVariables;
private ImmutableList<InlineFunctionState> inlineFunctionStates;
public PerFunctionState() {
additionalVariables = ImmutableList.empty();
inlineFunctionStates = ImmutableList.empty();
}
public void addVariable(Variable variable) {
additionalVariables = additionalVariables.cons(variable);
}
public ImmutableList<Variable> getAdditionalVariables() {
return additionalVariables;
}
| public InlineFunctionState enterInlineFunction(LocalReference returnVar, BreakTarget endOfFunction) { |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/PerFunctionState.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BreakTarget.java
// public class BreakTarget implements Node { // no-op. target of a break.
//
// public BreakTarget() {
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node == this;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LocalReference.java
// public class LocalReference implements NodeWithValue {
// @Nonnull
// public Variable variable;
//
//
// public LocalReference(@Nonnull Variable variable) {
// this.variable = variable;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == LocalReference.class && this.variable.equals(((LocalReference) node).variable);
// }
// }
| import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.BreakTarget;
import com.shapesecurity.shift.es2017.semantics.asg.LocalReference; | package com.shapesecurity.shift.es2017.semantics;
public class PerFunctionState {
private ImmutableList<Variable> additionalVariables;
private ImmutableList<InlineFunctionState> inlineFunctionStates;
public PerFunctionState() {
additionalVariables = ImmutableList.empty();
inlineFunctionStates = ImmutableList.empty();
}
public void addVariable(Variable variable) {
additionalVariables = additionalVariables.cons(variable);
}
public ImmutableList<Variable> getAdditionalVariables() {
return additionalVariables;
}
| // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BreakTarget.java
// public class BreakTarget implements Node { // no-op. target of a break.
//
// public BreakTarget() {
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node == this;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LocalReference.java
// public class LocalReference implements NodeWithValue {
// @Nonnull
// public Variable variable;
//
//
// public LocalReference(@Nonnull Variable variable) {
// this.variable = variable;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == LocalReference.class && this.variable.equals(((LocalReference) node).variable);
// }
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/PerFunctionState.java
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.BreakTarget;
import com.shapesecurity.shift.es2017.semantics.asg.LocalReference;
package com.shapesecurity.shift.es2017.semantics;
public class PerFunctionState {
private ImmutableList<Variable> additionalVariables;
private ImmutableList<InlineFunctionState> inlineFunctionStates;
public PerFunctionState() {
additionalVariables = ImmutableList.empty();
inlineFunctionStates = ImmutableList.empty();
}
public void addVariable(Variable variable) {
additionalVariables = additionalVariables.cons(variable);
}
public ImmutableList<Variable> getAdditionalVariables() {
return additionalVariables;
}
| public InlineFunctionState enterInlineFunction(LocalReference returnVar, BreakTarget endOfFunction) { |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Break.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/BrokenThrough.java
// public enum BrokenThrough {
// TRY_WITHOUT_FINALLY,
// TRY_WITH_FINALLY,
// FINALLY
// // We don't include "catch" because we are not aware of a consumer which needs that information, but it would be fine to include also
// }
| import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.semantics.BrokenThrough;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg;
public class Break implements Node {
@Nonnull
public final BreakTarget target;
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/BrokenThrough.java
// public enum BrokenThrough {
// TRY_WITHOUT_FINALLY,
// TRY_WITH_FINALLY,
// FINALLY
// // We don't include "catch" because we are not aware of a consumer which needs that information, but it would be fine to include also
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Break.java
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.semantics.BrokenThrough;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg;
public class Break implements Node {
@Nonnull
public final BreakTarget target;
@Nonnull | public final ImmutableList<BrokenThrough> broken; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/EqualityChecker.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
| import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import javax.annotation.Nonnull;
import java.util.Iterator; | package com.shapesecurity.shift.es2017.semantics.visitor;
public final class EqualityChecker {
private EqualityChecker() {
}
| // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/EqualityChecker.java
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import javax.annotation.Nonnull;
import java.util.Iterator;
package com.shapesecurity.shift.es2017.semantics.visitor;
public final class EqualityChecker {
private EqualityChecker() {
}
| public static boolean nodesAreEqual(@Nonnull Node node1, @Nonnull Node node2) { |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/Logic.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class Logic extends BinaryOperation {
@Nonnull
public final Operator operator;
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/Logic.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class Logic extends BinaryOperation {
@Nonnull
public final Operator operator;
@Nonnull | public final NodeWithValue left; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/IntMath.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class IntMath extends BinaryOperation {
@Nonnull
public final Operator operator;
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/IntMath.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class IntMath extends BinaryOperation {
@Nonnull
public final Operator operator;
@Nonnull | public final NodeWithValue left; |
shapesecurity/shift-semantics-java | src/test/java/com/shapesecurity/shift/es2017/semantics/GetDescendentsTest.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/GetDescendents.java
// public final class GetDescendents extends MonoidalReducer<ConcatList<Node>> {
//
// public static ImmutableList<Node> getDescendants(@Nonnull Node node) {
// return new Director<>(new GetDescendents()).reduceNode(node).toList();
// }
//
// private GetDescendents() {
// super(new Monoid.ConcatListAppend<>());
// }
//
// @Nonnull
// @Override
// public ConcatList<Node> reduceAll(@Nonnull Node node, @Nonnull ConcatList<Node> reduced) {
// return reduced.append1(node);
// }
// }
| import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.parser.Parser;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.visitor.GetDescendents;
import org.junit.Test;
import javax.annotation.Nonnull;
import java.nio.charset.StandardCharsets;
import java.util.IdentityHashMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue; | package com.shapesecurity.shift.es2017.semantics;
public class GetDescendentsTest {
// copied from JDK 10 java.lang.StringLatin1 to ensure consistency across JVM implementations
private static int hashCode(byte[] value) {
int h = 0;
for (byte v : value) {
h = 31 * h + (v & 0xff);
}
return h;
}
@Test
public void testVisitor() throws Exception {
String programText = "var z; typeof a; eval; ({ set a(b) { a = 0; }, get a(){} }).a = 0; " +
"(function() { 'use strict'; try { undefined = 0; } catch (e) {} })(); " +
"({a: 1}).a+(-1)+1-1*1/1%1|1&1^1<<1>>>1>>1; b = 1<1>1<=1>=1==1===1!=1!==!1;" +
"b++; b in {}; f = (function (a) { return typeof 1;});" +
"f(); f(1); f(1, []); f(1, [], null); f(1, [], null, this); f(1, [], null, this, /a/g); new f;" +
"delete b; if (true) delete { a: 1}.a; if (false) ; else a = ~1; try { throw 'err'; } catch (e) {};" +
"a instanceof Number; a = 2e308; a = 1.1; o = {}; (function() { 'use strict'; f(this); o.a = 1; delete o.a; })();" +
"a = {'a':1}; for (b in a) ;" +
"i = 1, j = 1; switch(i) { case --j: break; }" +
"(function(a){arguments = {0:'a', 1:'b'}; arguments[0]=1; c = arguments[0]})(2);" +
"(function A() { \n" +
" try { a = 1; return a;} catch(e) { a = 5; } finally { a = 2;}\n" +
"})();" +
"(function A() { \n" +
" label: try { } finally { break label; }; return 0;\n" +
"})();";
Semantics asg = Explicator.deriveSemantics(Parser.parseScript(programText)); | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/GetDescendents.java
// public final class GetDescendents extends MonoidalReducer<ConcatList<Node>> {
//
// public static ImmutableList<Node> getDescendants(@Nonnull Node node) {
// return new Director<>(new GetDescendents()).reduceNode(node).toList();
// }
//
// private GetDescendents() {
// super(new Monoid.ConcatListAppend<>());
// }
//
// @Nonnull
// @Override
// public ConcatList<Node> reduceAll(@Nonnull Node node, @Nonnull ConcatList<Node> reduced) {
// return reduced.append1(node);
// }
// }
// Path: src/test/java/com/shapesecurity/shift/es2017/semantics/GetDescendentsTest.java
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.parser.Parser;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.visitor.GetDescendents;
import org.junit.Test;
import javax.annotation.Nonnull;
import java.nio.charset.StandardCharsets;
import java.util.IdentityHashMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
package com.shapesecurity.shift.es2017.semantics;
public class GetDescendentsTest {
// copied from JDK 10 java.lang.StringLatin1 to ensure consistency across JVM implementations
private static int hashCode(byte[] value) {
int h = 0;
for (byte v : value) {
h = 31 * h + (v & 0xff);
}
return h;
}
@Test
public void testVisitor() throws Exception {
String programText = "var z; typeof a; eval; ({ set a(b) { a = 0; }, get a(){} }).a = 0; " +
"(function() { 'use strict'; try { undefined = 0; } catch (e) {} })(); " +
"({a: 1}).a+(-1)+1-1*1/1%1|1&1^1<<1>>>1>>1; b = 1<1>1<=1>=1==1===1!=1!==!1;" +
"b++; b in {}; f = (function (a) { return typeof 1;});" +
"f(); f(1); f(1, []); f(1, [], null); f(1, [], null, this); f(1, [], null, this, /a/g); new f;" +
"delete b; if (true) delete { a: 1}.a; if (false) ; else a = ~1; try { throw 'err'; } catch (e) {};" +
"a instanceof Number; a = 2e308; a = 1.1; o = {}; (function() { 'use strict'; f(this); o.a = 1; delete o.a; })();" +
"a = {'a':1}; for (b in a) ;" +
"i = 1, j = 1; switch(i) { case --j: break; }" +
"(function(a){arguments = {0:'a', 1:'b'}; arguments[0]=1; c = arguments[0]})(2);" +
"(function A() { \n" +
" try { a = 1; return a;} catch(e) { a = 5; } finally { a = 2;}\n" +
"})();" +
"(function A() { \n" +
" label: try { } finally { break label; }; return 0;\n" +
"})();";
Semantics asg = Explicator.deriveSemantics(Parser.parseScript(programText)); | ImmutableList<Node> nodes = GetDescendents.getDescendants(asg.node); |
shapesecurity/shift-semantics-java | src/test/java/com/shapesecurity/shift/es2017/semantics/GetDescendentsTest.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/GetDescendents.java
// public final class GetDescendents extends MonoidalReducer<ConcatList<Node>> {
//
// public static ImmutableList<Node> getDescendants(@Nonnull Node node) {
// return new Director<>(new GetDescendents()).reduceNode(node).toList();
// }
//
// private GetDescendents() {
// super(new Monoid.ConcatListAppend<>());
// }
//
// @Nonnull
// @Override
// public ConcatList<Node> reduceAll(@Nonnull Node node, @Nonnull ConcatList<Node> reduced) {
// return reduced.append1(node);
// }
// }
| import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.parser.Parser;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.visitor.GetDescendents;
import org.junit.Test;
import javax.annotation.Nonnull;
import java.nio.charset.StandardCharsets;
import java.util.IdentityHashMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue; | package com.shapesecurity.shift.es2017.semantics;
public class GetDescendentsTest {
// copied from JDK 10 java.lang.StringLatin1 to ensure consistency across JVM implementations
private static int hashCode(byte[] value) {
int h = 0;
for (byte v : value) {
h = 31 * h + (v & 0xff);
}
return h;
}
@Test
public void testVisitor() throws Exception {
String programText = "var z; typeof a; eval; ({ set a(b) { a = 0; }, get a(){} }).a = 0; " +
"(function() { 'use strict'; try { undefined = 0; } catch (e) {} })(); " +
"({a: 1}).a+(-1)+1-1*1/1%1|1&1^1<<1>>>1>>1; b = 1<1>1<=1>=1==1===1!=1!==!1;" +
"b++; b in {}; f = (function (a) { return typeof 1;});" +
"f(); f(1); f(1, []); f(1, [], null); f(1, [], null, this); f(1, [], null, this, /a/g); new f;" +
"delete b; if (true) delete { a: 1}.a; if (false) ; else a = ~1; try { throw 'err'; } catch (e) {};" +
"a instanceof Number; a = 2e308; a = 1.1; o = {}; (function() { 'use strict'; f(this); o.a = 1; delete o.a; })();" +
"a = {'a':1}; for (b in a) ;" +
"i = 1, j = 1; switch(i) { case --j: break; }" +
"(function(a){arguments = {0:'a', 1:'b'}; arguments[0]=1; c = arguments[0]})(2);" +
"(function A() { \n" +
" try { a = 1; return a;} catch(e) { a = 5; } finally { a = 2;}\n" +
"})();" +
"(function A() { \n" +
" label: try { } finally { break label; }; return 0;\n" +
"})();";
Semantics asg = Explicator.deriveSemantics(Parser.parseScript(programText)); | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/GetDescendents.java
// public final class GetDescendents extends MonoidalReducer<ConcatList<Node>> {
//
// public static ImmutableList<Node> getDescendants(@Nonnull Node node) {
// return new Director<>(new GetDescendents()).reduceNode(node).toList();
// }
//
// private GetDescendents() {
// super(new Monoid.ConcatListAppend<>());
// }
//
// @Nonnull
// @Override
// public ConcatList<Node> reduceAll(@Nonnull Node node, @Nonnull ConcatList<Node> reduced) {
// return reduced.append1(node);
// }
// }
// Path: src/test/java/com/shapesecurity/shift/es2017/semantics/GetDescendentsTest.java
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.parser.Parser;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.visitor.GetDescendents;
import org.junit.Test;
import javax.annotation.Nonnull;
import java.nio.charset.StandardCharsets;
import java.util.IdentityHashMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
package com.shapesecurity.shift.es2017.semantics;
public class GetDescendentsTest {
// copied from JDK 10 java.lang.StringLatin1 to ensure consistency across JVM implementations
private static int hashCode(byte[] value) {
int h = 0;
for (byte v : value) {
h = 31 * h + (v & 0xff);
}
return h;
}
@Test
public void testVisitor() throws Exception {
String programText = "var z; typeof a; eval; ({ set a(b) { a = 0; }, get a(){} }).a = 0; " +
"(function() { 'use strict'; try { undefined = 0; } catch (e) {} })(); " +
"({a: 1}).a+(-1)+1-1*1/1%1|1&1^1<<1>>>1>>1; b = 1<1>1<=1>=1==1===1!=1!==!1;" +
"b++; b in {}; f = (function (a) { return typeof 1;});" +
"f(); f(1); f(1, []); f(1, [], null); f(1, [], null, this); f(1, [], null, this, /a/g); new f;" +
"delete b; if (true) delete { a: 1}.a; if (false) ; else a = ~1; try { throw 'err'; } catch (e) {};" +
"a instanceof Number; a = 2e308; a = 1.1; o = {}; (function() { 'use strict'; f(this); o.a = 1; delete o.a; })();" +
"a = {'a':1}; for (b in a) ;" +
"i = 1, j = 1; switch(i) { case --j: break; }" +
"(function(a){arguments = {0:'a', 1:'b'}; arguments[0]=1; c = arguments[0]})(2);" +
"(function A() { \n" +
" try { a = 1; return a;} catch(e) { a = 5; } finally { a = 2;}\n" +
"})();" +
"(function A() { \n" +
" label: try { } finally { break label; }; return 0;\n" +
"})();";
Semantics asg = Explicator.deriveSemantics(Parser.parseScript(programText)); | ImmutableList<Node> nodes = GetDescendents.getDescendants(asg.node); |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/Equality.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class Equality extends BinaryOperation {
@Nonnull
public final Operator operator;
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/Equality.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class Equality extends BinaryOperation {
@Nonnull
public final Operator operator;
@Nonnull | public final NodeWithValue left; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/CompletionRecord.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BreakTarget.java
// public class BreakTarget implements Node { // no-op. target of a break.
//
// public BreakTarget() {
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node == this;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.BreakTarget;
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import java.util.function.Function; | package com.shapesecurity.shift.es2017.semantics.visitor;
public abstract class CompletionRecord {
// modelling ReturnIfAbrupt
public abstract <T extends NodeWithValue> CompletionRecord mapNormal(Function<? super NodeWithValue, T> f);
public static class Normal extends CompletionRecord {
public final NodeWithValue value;
Normal(NodeWithValue value) {
this.value = value;
}
@Override
public <T extends NodeWithValue> Normal mapNormal(Function<? super NodeWithValue, T> f) {
return new Normal(f.apply(this.value));
}
}
public static class Break extends CompletionRecord { | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BreakTarget.java
// public class BreakTarget implements Node { // no-op. target of a break.
//
// public BreakTarget() {
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node == this;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/CompletionRecord.java
import com.shapesecurity.shift.es2017.semantics.asg.BreakTarget;
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import java.util.function.Function;
package com.shapesecurity.shift.es2017.semantics.visitor;
public abstract class CompletionRecord {
// modelling ReturnIfAbrupt
public abstract <T extends NodeWithValue> CompletionRecord mapNormal(Function<? super NodeWithValue, T> f);
public static class Normal extends CompletionRecord {
public final NodeWithValue value;
Normal(NodeWithValue value) {
this.value = value;
}
@Override
public <T extends NodeWithValue> Normal mapNormal(Function<? super NodeWithValue, T> f) {
return new Normal(f.apply(this.value));
}
}
public static class Break extends CompletionRecord { | public final BreakTarget target; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/UnaryOperation/BitwiseNot.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.UnaryOperation;
public class BitwiseNot extends UnaryOperation {
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/UnaryOperation/BitwiseNot.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.UnaryOperation;
public class BitwiseNot extends UnaryOperation {
@Nonnull | public final NodeWithValue expression; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/UnaryOperation/Not.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.UnaryOperation;
public class Not extends UnaryOperation {
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/UnaryOperation/Not.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.UnaryOperation;
public class Not extends UnaryOperation {
@Nonnull | public final NodeWithValue expression; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/InstanceOf.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class InstanceOf extends BinaryOperation {
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/InstanceOf.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class InstanceOf extends BinaryOperation {
@Nonnull | public final NodeWithValue left; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/UnaryOperation/Typeof.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.UnaryOperation;
// Expression must not be an undefined reference.
public class Typeof extends UnaryOperation {
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/UnaryOperation/Typeof.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.UnaryOperation;
// Expression must not be an undefined reference.
public class Typeof extends UnaryOperation {
@Nonnull | public final NodeWithValue expression; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/Semantics.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/EqualityChecker.java
// public final class EqualityChecker {
//
// private EqualityChecker() {
//
// }
//
// public static boolean nodesAreEqual(@Nonnull Node node1, @Nonnull Node node2) {
// if (node1 == node2) {
// return true;
// }
// if (!node1.equalsIgnoringChildren(node2)) {
// return false;
// }
// ImmutableList<Node> nodeList1 = GetDescendents.getDescendants(node1);
// ImmutableList<Node> nodeList2 = GetDescendents.getDescendants(node2);
// if (nodeList1.length != nodeList2.length) {
// return false;
// }
// Iterator<Node> node1Iterator = nodeList1.iterator();
// Iterator<Node> node2Iterator = nodeList2.iterator();
// while (node1Iterator.hasNext() && node2Iterator.hasNext()) {
// if (!node1Iterator.next().equalsIgnoringChildren(node2Iterator.next())) {
// return false;
// }
// }
// return !node1Iterator.hasNext() && !node2Iterator.hasNext();
// }
//
// }
| import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.ScopeLookup;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.visitor.EqualityChecker;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.IdentityHashMap;
import java.util.stream.Collectors; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics;
public class Semantics {
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/EqualityChecker.java
// public final class EqualityChecker {
//
// private EqualityChecker() {
//
// }
//
// public static boolean nodesAreEqual(@Nonnull Node node1, @Nonnull Node node2) {
// if (node1 == node2) {
// return true;
// }
// if (!node1.equalsIgnoringChildren(node2)) {
// return false;
// }
// ImmutableList<Node> nodeList1 = GetDescendents.getDescendants(node1);
// ImmutableList<Node> nodeList2 = GetDescendents.getDescendants(node2);
// if (nodeList1.length != nodeList2.length) {
// return false;
// }
// Iterator<Node> node1Iterator = nodeList1.iterator();
// Iterator<Node> node2Iterator = nodeList2.iterator();
// while (node1Iterator.hasNext() && node2Iterator.hasNext()) {
// if (!node1Iterator.next().equalsIgnoringChildren(node2Iterator.next())) {
// return false;
// }
// }
// return !node1Iterator.hasNext() && !node2Iterator.hasNext();
// }
//
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/Semantics.java
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.ScopeLookup;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.visitor.EqualityChecker;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.IdentityHashMap;
import java.util.stream.Collectors;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics;
public class Semantics {
@Nonnull | public final Node node; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/Semantics.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/EqualityChecker.java
// public final class EqualityChecker {
//
// private EqualityChecker() {
//
// }
//
// public static boolean nodesAreEqual(@Nonnull Node node1, @Nonnull Node node2) {
// if (node1 == node2) {
// return true;
// }
// if (!node1.equalsIgnoringChildren(node2)) {
// return false;
// }
// ImmutableList<Node> nodeList1 = GetDescendents.getDescendants(node1);
// ImmutableList<Node> nodeList2 = GetDescendents.getDescendants(node2);
// if (nodeList1.length != nodeList2.length) {
// return false;
// }
// Iterator<Node> node1Iterator = nodeList1.iterator();
// Iterator<Node> node2Iterator = nodeList2.iterator();
// while (node1Iterator.hasNext() && node2Iterator.hasNext()) {
// if (!node1Iterator.next().equalsIgnoringChildren(node2Iterator.next())) {
// return false;
// }
// }
// return !node1Iterator.hasNext() && !node2Iterator.hasNext();
// }
//
// }
| import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.ScopeLookup;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.visitor.EqualityChecker;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.IdentityHashMap;
import java.util.stream.Collectors; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics;
public class Semantics {
@Nonnull
public final Node node;
@Nonnull
public final ImmutableList<Variable> locals;
@Nonnull
public final ImmutableList<String> scriptVarDecls;
@Nonnull
public final ScopeLookup scopeLookup;
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/EqualityChecker.java
// public final class EqualityChecker {
//
// private EqualityChecker() {
//
// }
//
// public static boolean nodesAreEqual(@Nonnull Node node1, @Nonnull Node node2) {
// if (node1 == node2) {
// return true;
// }
// if (!node1.equalsIgnoringChildren(node2)) {
// return false;
// }
// ImmutableList<Node> nodeList1 = GetDescendents.getDescendants(node1);
// ImmutableList<Node> nodeList2 = GetDescendents.getDescendants(node2);
// if (nodeList1.length != nodeList2.length) {
// return false;
// }
// Iterator<Node> node1Iterator = nodeList1.iterator();
// Iterator<Node> node2Iterator = nodeList2.iterator();
// while (node1Iterator.hasNext() && node2Iterator.hasNext()) {
// if (!node1Iterator.next().equalsIgnoringChildren(node2Iterator.next())) {
// return false;
// }
// }
// return !node1Iterator.hasNext() && !node2Iterator.hasNext();
// }
//
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/Semantics.java
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.ScopeLookup;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.visitor.EqualityChecker;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.IdentityHashMap;
import java.util.stream.Collectors;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics;
public class Semantics {
@Nonnull
public final Node node;
@Nonnull
public final ImmutableList<Variable> locals;
@Nonnull
public final ImmutableList<String> scriptVarDecls;
@Nonnull
public final ScopeLookup scopeLookup;
@Nonnull | public final IdentityHashMap<LiteralFunction, Scope> functionScopes; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/Semantics.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/EqualityChecker.java
// public final class EqualityChecker {
//
// private EqualityChecker() {
//
// }
//
// public static boolean nodesAreEqual(@Nonnull Node node1, @Nonnull Node node2) {
// if (node1 == node2) {
// return true;
// }
// if (!node1.equalsIgnoringChildren(node2)) {
// return false;
// }
// ImmutableList<Node> nodeList1 = GetDescendents.getDescendants(node1);
// ImmutableList<Node> nodeList2 = GetDescendents.getDescendants(node2);
// if (nodeList1.length != nodeList2.length) {
// return false;
// }
// Iterator<Node> node1Iterator = nodeList1.iterator();
// Iterator<Node> node2Iterator = nodeList2.iterator();
// while (node1Iterator.hasNext() && node2Iterator.hasNext()) {
// if (!node1Iterator.next().equalsIgnoringChildren(node2Iterator.next())) {
// return false;
// }
// }
// return !node1Iterator.hasNext() && !node2Iterator.hasNext();
// }
//
// }
| import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.ScopeLookup;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.visitor.EqualityChecker;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.IdentityHashMap;
import java.util.stream.Collectors; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics;
public class Semantics {
@Nonnull
public final Node node;
@Nonnull
public final ImmutableList<Variable> locals;
@Nonnull
public final ImmutableList<String> scriptVarDecls;
@Nonnull
public final ScopeLookup scopeLookup;
@Nonnull
public final IdentityHashMap<LiteralFunction, Scope> functionScopes;
public Semantics(@Nonnull Node node, @Nonnull ImmutableList<Variable> locals, @Nonnull ImmutableList<String> scriptVarDecls, @Nonnull ScopeLookup scopeLookup, @Nonnull IdentityHashMap<LiteralFunction, Scope> functionScopes) {
this.node = node;
this.locals = locals;
this.scriptVarDecls = scriptVarDecls;
this.scopeLookup = scopeLookup;
this.functionScopes = functionScopes;
}
@Override
public boolean equals(@Nullable Object other) {
if (!(other instanceof Semantics)) {
return false;
}
// other fields are metadata generated from node, effectively. | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LiteralFunction.java
// public class LiteralFunction implements Literal {
// @Nonnull
// public final Maybe<Variable> name;
// @Nonnull
// public final Maybe<Variable> arguments;
// @Nonnull
// public final ImmutableList<Variable> parameters;
// @Nonnull
// public final ImmutableList<Variable> locals;
//
//
// @Nonnull
// public final ImmutableList<Variable> captured;
// @Nonnull
// public final Block body;
// @Nonnull
// public final boolean isStrict;
//
// public LiteralFunction(
// @Nonnull Maybe<Variable> name, @Nonnull Maybe<Variable> arguments, @Nonnull ImmutableList<Variable> parameters, @Nonnull ImmutableList<Variable> locals,
// @Nonnull ImmutableList<Variable> captured, @Nonnull Block body, boolean isStrict
// ) {
// this.name = name;
// this.arguments = arguments;
// this.parameters = parameters;
// this.locals = locals;
// this.captured = captured;
// this.body = body;
// this.isStrict = isStrict;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node instanceof LiteralFunction &&
// this.name.equals(((LiteralFunction) node).name) &&
// this.arguments.equals(((LiteralFunction) node).arguments) &&
// this.parameters.equals(((LiteralFunction) node).parameters) &&
// this.locals.equals(((LiteralFunction) node).locals) &&
// this.captured.equals(((LiteralFunction) node).captured) &&
// this.isStrict == ((LiteralFunction) node).isStrict;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/Node.java
// public interface Node {
//
// default boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == this.getClass();
// }
//
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/EqualityChecker.java
// public final class EqualityChecker {
//
// private EqualityChecker() {
//
// }
//
// public static boolean nodesAreEqual(@Nonnull Node node1, @Nonnull Node node2) {
// if (node1 == node2) {
// return true;
// }
// if (!node1.equalsIgnoringChildren(node2)) {
// return false;
// }
// ImmutableList<Node> nodeList1 = GetDescendents.getDescendants(node1);
// ImmutableList<Node> nodeList2 = GetDescendents.getDescendants(node2);
// if (nodeList1.length != nodeList2.length) {
// return false;
// }
// Iterator<Node> node1Iterator = nodeList1.iterator();
// Iterator<Node> node2Iterator = nodeList2.iterator();
// while (node1Iterator.hasNext() && node2Iterator.hasNext()) {
// if (!node1Iterator.next().equalsIgnoringChildren(node2Iterator.next())) {
// return false;
// }
// }
// return !node1Iterator.hasNext() && !node2Iterator.hasNext();
// }
//
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/Semantics.java
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.shift.es2017.scope.Scope;
import com.shapesecurity.shift.es2017.scope.ScopeLookup;
import com.shapesecurity.shift.es2017.scope.Variable;
import com.shapesecurity.shift.es2017.semantics.asg.LiteralFunction;
import com.shapesecurity.shift.es2017.semantics.asg.Node;
import com.shapesecurity.shift.es2017.semantics.visitor.EqualityChecker;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.IdentityHashMap;
import java.util.stream.Collectors;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics;
public class Semantics {
@Nonnull
public final Node node;
@Nonnull
public final ImmutableList<Variable> locals;
@Nonnull
public final ImmutableList<String> scriptVarDecls;
@Nonnull
public final ScopeLookup scopeLookup;
@Nonnull
public final IdentityHashMap<LiteralFunction, Scope> functionScopes;
public Semantics(@Nonnull Node node, @Nonnull ImmutableList<Variable> locals, @Nonnull ImmutableList<String> scriptVarDecls, @Nonnull ScopeLookup scopeLookup, @Nonnull IdentityHashMap<LiteralFunction, Scope> functionScopes) {
this.node = node;
this.locals = locals;
this.scriptVarDecls = scriptVarDecls;
this.scopeLookup = scopeLookup;
this.functionScopes = functionScopes;
}
@Override
public boolean equals(@Nullable Object other) {
if (!(other instanceof Semantics)) {
return false;
}
// other fields are metadata generated from node, effectively. | return EqualityChecker.nodesAreEqual(this.node, ((Semantics) other).node); |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/RelationalComparison.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class RelationalComparison extends BinaryOperation {
@Nonnull
public final Operator operator;
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BinaryOperation/RelationalComparison.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.BinaryOperation;
public class RelationalComparison extends BinaryOperation {
@Nonnull
public final Operator operator;
@Nonnull | public final NodeWithValue left; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/ReturnAfterFinallies.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/BrokenThrough.java
// public enum BrokenThrough {
// TRY_WITHOUT_FINALLY,
// TRY_WITH_FINALLY,
// FINALLY
// // We don't include "catch" because we are not aware of a consumer which needs that information, but it would be fine to include also
// }
| import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.semantics.BrokenThrough;
import javax.annotation.Nonnull; | package com.shapesecurity.shift.es2017.semantics.asg;
public class ReturnAfterFinallies implements Node {
@Nonnull
public final Maybe<LocalReference> savedValue;
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/BrokenThrough.java
// public enum BrokenThrough {
// TRY_WITHOUT_FINALLY,
// TRY_WITH_FINALLY,
// FINALLY
// // We don't include "catch" because we are not aware of a consumer which needs that information, but it would be fine to include also
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/ReturnAfterFinallies.java
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.semantics.BrokenThrough;
import javax.annotation.Nonnull;
package com.shapesecurity.shift.es2017.semantics.asg;
public class ReturnAfterFinallies implements Node {
@Nonnull
public final Maybe<LocalReference> savedValue;
@Nonnull | public final ImmutableList<BrokenThrough> broken; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/FinallyJumpReducer.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/BrokenThrough.java
// public enum BrokenThrough {
// TRY_WITHOUT_FINALLY,
// TRY_WITH_FINALLY,
// FINALLY
// // We don't include "catch" because we are not aware of a consumer which needs that information, but it would be fine to include also
// }
| import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.HashTable;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.functional.data.Monoid;
import com.shapesecurity.shift.es2017.ast.*;
import com.shapesecurity.shift.es2017.ast.Module;
import com.shapesecurity.shift.es2017.semantics.BrokenThrough;
import com.shapesecurity.shift.es2017.reducer.Director;
import com.shapesecurity.shift.es2017.reducer.MonoidalReducer;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.visitor;
// Almost identical to JumpReducer, but also tracks the number of finally clauses that a jump exits (i.e., 'finally {...}' blocks that a 'break' or 'return' is within and its target is not)
// Gives a map from break/continue statements to the statement/loop broken and return statements to the function body being returned. For labelled statements, map goes to the body of the statement, not the LabelledStatement
// Relies on the AST being valid: in particular, does not check that labelled continues are breaking loops rather than just statements.
// TODO could be waaaaay more typesafe than a map from nodes to nodes.
public class FinallyJumpReducer extends MonoidalReducer<FinallyJumpReducer.State> {
@Nonnull
public static final FinallyJumpReducer INSTANCE = new FinallyJumpReducer();
private FinallyJumpReducer() {
super(new StateMonoid());
}
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/BrokenThrough.java
// public enum BrokenThrough {
// TRY_WITHOUT_FINALLY,
// TRY_WITH_FINALLY,
// FINALLY
// // We don't include "catch" because we are not aware of a consumer which needs that information, but it would be fine to include also
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/visitor/FinallyJumpReducer.java
import com.shapesecurity.functional.Pair;
import com.shapesecurity.functional.data.HashTable;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.functional.data.Monoid;
import com.shapesecurity.shift.es2017.ast.*;
import com.shapesecurity.shift.es2017.ast.Module;
import com.shapesecurity.shift.es2017.semantics.BrokenThrough;
import com.shapesecurity.shift.es2017.reducer.Director;
import com.shapesecurity.shift.es2017.reducer.MonoidalReducer;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.visitor;
// Almost identical to JumpReducer, but also tracks the number of finally clauses that a jump exits (i.e., 'finally {...}' blocks that a 'break' or 'return' is within and its target is not)
// Gives a map from break/continue statements to the statement/loop broken and return statements to the function body being returned. For labelled statements, map goes to the body of the statement, not the LabelledStatement
// Relies on the AST being valid: in particular, does not check that labelled continues are breaking loops rather than just statements.
// TODO could be waaaaay more typesafe than a map from nodes to nodes.
public class FinallyJumpReducer extends MonoidalReducer<FinallyJumpReducer.State> {
@Nonnull
public static final FinallyJumpReducer INSTANCE = new FinallyJumpReducer();
private FinallyJumpReducer() {
super(new StateMonoid());
}
@Nonnull | public static HashTable<Node, Pair<Node, ImmutableList<BrokenThrough>>> extract(@Nonnull FinallyJumpReducer.State state) { |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/InlineFunctionState.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BreakTarget.java
// public class BreakTarget implements Node { // no-op. target of a break.
//
// public BreakTarget() {
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node == this;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LocalReference.java
// public class LocalReference implements NodeWithValue {
// @Nonnull
// public Variable variable;
//
//
// public LocalReference(@Nonnull Variable variable) {
// this.variable = variable;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == LocalReference.class && this.variable.equals(((LocalReference) node).variable);
// }
// }
| import com.shapesecurity.shift.es2017.semantics.asg.BreakTarget;
import com.shapesecurity.shift.es2017.semantics.asg.LocalReference; | package com.shapesecurity.shift.es2017.semantics;
public class InlineFunctionState {
private final LocalReference returnVar; | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/BreakTarget.java
// public class BreakTarget implements Node { // no-op. target of a break.
//
// public BreakTarget() {
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node == this;
// }
// }
//
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/LocalReference.java
// public class LocalReference implements NodeWithValue {
// @Nonnull
// public Variable variable;
//
//
// public LocalReference(@Nonnull Variable variable) {
// this.variable = variable;
// }
//
// @Override
// public boolean equalsIgnoringChildren(@Nonnull Node node) {
// return node.getClass() == LocalReference.class && this.variable.equals(((LocalReference) node).variable);
// }
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/InlineFunctionState.java
import com.shapesecurity.shift.es2017.semantics.asg.BreakTarget;
import com.shapesecurity.shift.es2017.semantics.asg.LocalReference;
package com.shapesecurity.shift.es2017.semantics;
public class InlineFunctionState {
private final LocalReference returnVar; | private final BreakTarget endOfFunction; |
shapesecurity/shift-semantics-java | src/main/java/com/shapesecurity/shift/es2017/semantics/asg/UnaryOperation/Negation.java | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
| import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull; | /*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.UnaryOperation;
public class Negation extends UnaryOperation {
@Nonnull | // Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/NodeWithValue.java
// public interface NodeWithValue extends Node {
// }
// Path: src/main/java/com/shapesecurity/shift/es2017/semantics/asg/UnaryOperation/Negation.java
import com.shapesecurity.shift.es2017.semantics.asg.NodeWithValue;
import javax.annotation.Nonnull;
/*
* Copyright 2016 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.semantics.asg.UnaryOperation;
public class Negation extends UnaryOperation {
@Nonnull | public final NodeWithValue expression; |
dadrus/jpa-unit | junit4-extension/src/test/java/eu/drus/jpa/unit/rule/TestClassStatementTest.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.times;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.model.Statement;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.rule;
@RunWith(MockitoJUnitRunner.class)
public class TestClassStatementTest {
@Mock | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: junit4-extension/src/test/java/eu/drus/jpa/unit/rule/TestClassStatementTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.times;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.model.Statement;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.rule;
@RunWith(MockitoJUnitRunner.class)
public class TestClassStatementTest {
@Mock | private ExecutionContext ctx; |
dadrus/jpa-unit | junit4-extension/src/test/java/eu/drus/jpa/unit/rule/TestClassStatementTest.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.times;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.model.Statement;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.rule;
@RunWith(MockitoJUnitRunner.class)
public class TestClassStatementTest {
@Mock
private ExecutionContext ctx;
@Mock
private Statement base;
@Mock | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: junit4-extension/src/test/java/eu/drus/jpa/unit/rule/TestClassStatementTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.times;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.model.Statement;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.rule;
@RunWith(MockitoJUnitRunner.class)
public class TestClassStatementTest {
@Mock
private ExecutionContext ctx;
@Mock
private Statement base;
@Mock | private DecoratorExecutor jpaUnit; |
dadrus/jpa-unit | junit4-extension/src/test/java/eu/drus/jpa/unit/rule/TestClassStatementTest.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.times;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.model.Statement;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.rule;
@RunWith(MockitoJUnitRunner.class)
public class TestClassStatementTest {
@Mock
private ExecutionContext ctx;
@Mock
private Statement base;
@Mock
private DecoratorExecutor jpaUnit;
private TestClassStatement statement;
private Map<String, Object> map = new HashMap<>();
@Before
public void setUp() {
doAnswer((final InvocationOnMock invocation) -> {
final String key = (String) invocation.getArguments()[0];
return map.get(key);
}).when(ctx).getData(anyString());
doAnswer((final InvocationOnMock invocation) -> {
final String key = (String) invocation.getArguments()[0];
final Object value = invocation.getArguments()[1];
return map.put(key, value);
}).when(ctx).storeData(anyString(), anyObject());
statement = new TestClassStatement(ctx, jpaUnit, base, this);
}
@Test
public void testOnMultipleEvaluateCallsBeforeAllAndAfterAllIsCalledOnlyOnce() throws Throwable {
// GIVEN
// WHEN
statement.evaluate();
statement.evaluate();
// THEN | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: junit4-extension/src/test/java/eu/drus/jpa/unit/rule/TestClassStatementTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.times;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.model.Statement;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.rule;
@RunWith(MockitoJUnitRunner.class)
public class TestClassStatementTest {
@Mock
private ExecutionContext ctx;
@Mock
private Statement base;
@Mock
private DecoratorExecutor jpaUnit;
private TestClassStatement statement;
private Map<String, Object> map = new HashMap<>();
@Before
public void setUp() {
doAnswer((final InvocationOnMock invocation) -> {
final String key = (String) invocation.getArguments()[0];
return map.get(key);
}).when(ctx).getData(anyString());
doAnswer((final InvocationOnMock invocation) -> {
final String key = (String) invocation.getArguments()[0];
final Object value = invocation.getArguments()[1];
return map.put(key, value);
}).when(ctx).storeData(anyString(), anyObject());
statement = new TestClassStatement(ctx, jpaUnit, base, this);
}
@Test
public void testOnMultipleEvaluateCallsBeforeAllAndAfterAllIsCalledOnlyOnce() throws Throwable {
// GIVEN
// WHEN
statement.evaluate();
statement.evaluate();
// THEN | final ArgumentCaptor<TestInvocation> invocationCaptor = ArgumentCaptor.forClass(TestInvocation.class); |
dadrus/jpa-unit | core/src/test/java/eu/drus/jpa/unit/decorator/jpa/PersistenceContextDecoratorTest.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.decorator.jpa;
@RunWith(MockitoJUnitRunner.class)
public class PersistenceContextDecoratorTest {
@Mock | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: core/src/test/java/eu/drus/jpa/unit/decorator/jpa/PersistenceContextDecoratorTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.decorator.jpa;
@RunWith(MockitoJUnitRunner.class)
public class PersistenceContextDecoratorTest {
@Mock | private TestInvocation invocation; |
dadrus/jpa-unit | core/src/test/java/eu/drus/jpa/unit/decorator/jpa/PersistenceContextDecoratorTest.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.decorator.jpa;
@RunWith(MockitoJUnitRunner.class)
public class PersistenceContextDecoratorTest {
@Mock
private TestInvocation invocation;
@Mock | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: core/src/test/java/eu/drus/jpa/unit/decorator/jpa/PersistenceContextDecoratorTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.decorator.jpa;
@RunWith(MockitoJUnitRunner.class)
public class PersistenceContextDecoratorTest {
@Mock
private TestInvocation invocation;
@Mock | private ExecutionContext ctx; |
dadrus/jpa-unit | core/src/test/java/eu/drus/jpa/unit/decorator/jpa/PersistenceContextDecoratorTest.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.decorator.jpa;
@RunWith(MockitoJUnitRunner.class)
public class PersistenceContextDecoratorTest {
@Mock
private TestInvocation invocation;
@Mock
private ExecutionContext ctx;
@Mock
private EntityManagerFactory entityManagerFactory;
@Mock
private EntityManager entityManager;
@PersistenceContext
private EntityManager em1;
@PersistenceContext(type = PersistenceContextType.EXTENDED)
private EntityManager em2;
@SuppressWarnings("unused")
private Object someField;
@Before
public void setupMocks() {
when(invocation.getContext()).thenReturn(ctx);
when(invocation.getTestInstance()).thenReturn(Optional.of(this)); | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: core/src/test/java/eu/drus/jpa/unit/decorator/jpa/PersistenceContextDecoratorTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.decorator.jpa;
@RunWith(MockitoJUnitRunner.class)
public class PersistenceContextDecoratorTest {
@Mock
private TestInvocation invocation;
@Mock
private ExecutionContext ctx;
@Mock
private EntityManagerFactory entityManagerFactory;
@Mock
private EntityManager entityManager;
@PersistenceContext
private EntityManager em1;
@PersistenceContext(type = PersistenceContextType.EXTENDED)
private EntityManager em2;
@SuppressWarnings("unused")
private Object someField;
@Before
public void setupMocks() {
when(invocation.getContext()).thenReturn(ctx);
when(invocation.getTestInstance()).thenReturn(Optional.of(this)); | when(ctx.getData(eq(Constants.KEY_ENTITY_MANAGER_FACTORY))).thenReturn(entityManagerFactory); |
dadrus/jpa-unit | neo4j/src/test/java/eu/drus/jpa/unit/neo4j/operation/RefreshOperationTest.java | // Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/test/entities/B.java
// @Entity
// public class B {
//
// @Id
// private Long id;
// }
| import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import org.jgrapht.Graph;
import org.jgrapht.graph.ClassBasedEdgeFactory;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
import com.google.common.collect.ImmutableMap;
import eu.drus.jpa.unit.neo4j.dataset.Edge;
import eu.drus.jpa.unit.neo4j.dataset.GraphElementFactory;
import eu.drus.jpa.unit.neo4j.dataset.Node;
import eu.drus.jpa.unit.neo4j.test.entities.A;
import eu.drus.jpa.unit.neo4j.test.entities.B; | package eu.drus.jpa.unit.neo4j.operation;
@RunWith(MockitoJUnitRunner.class)
public class RefreshOperationTest {
private GraphElementFactory graphElementFactory;
@Mock
private Connection connection;
@Spy
private RefreshOperation operation;
@Before
public void prepareMocks() throws SQLException {
doAnswer(i -> null).when(operation).executeQuery(any(Connection.class), anyString());
| // Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/test/entities/B.java
// @Entity
// public class B {
//
// @Id
// private Long id;
// }
// Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/operation/RefreshOperationTest.java
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import org.jgrapht.Graph;
import org.jgrapht.graph.ClassBasedEdgeFactory;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
import com.google.common.collect.ImmutableMap;
import eu.drus.jpa.unit.neo4j.dataset.Edge;
import eu.drus.jpa.unit.neo4j.dataset.GraphElementFactory;
import eu.drus.jpa.unit.neo4j.dataset.Node;
import eu.drus.jpa.unit.neo4j.test.entities.A;
import eu.drus.jpa.unit.neo4j.test.entities.B;
package eu.drus.jpa.unit.neo4j.operation;
@RunWith(MockitoJUnitRunner.class)
public class RefreshOperationTest {
private GraphElementFactory graphElementFactory;
@Mock
private Connection connection;
@Spy
private RefreshOperation operation;
@Before
public void prepareMocks() throws SQLException {
doAnswer(i -> null).when(operation).executeQuery(any(Connection.class), anyString());
| graphElementFactory = new GraphElementFactory(Arrays.asList(A.class, B.class)); |
dadrus/jpa-unit | neo4j/src/test/java/eu/drus/jpa/unit/neo4j/operation/UpdateOperationTest.java | // Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/test/entities/B.java
// @Entity
// public class B {
//
// @Id
// private Long id;
// }
| import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import org.jgrapht.Graph;
import org.jgrapht.graph.ClassBasedEdgeFactory;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
import com.google.common.collect.ImmutableMap;
import eu.drus.jpa.unit.neo4j.dataset.Edge;
import eu.drus.jpa.unit.neo4j.dataset.GraphElementFactory;
import eu.drus.jpa.unit.neo4j.dataset.Node;
import eu.drus.jpa.unit.neo4j.test.entities.A;
import eu.drus.jpa.unit.neo4j.test.entities.B; | package eu.drus.jpa.unit.neo4j.operation;
@RunWith(MockitoJUnitRunner.class)
public class UpdateOperationTest {
private GraphElementFactory graphElementFactory;
@Mock
private Connection connection;
@Spy
private UpdateOperation operation;
@Before
public void prepareMocks() throws SQLException {
doAnswer(i -> null).when(operation).executeQuery(any(Connection.class), anyString());
| // Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/test/entities/B.java
// @Entity
// public class B {
//
// @Id
// private Long id;
// }
// Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/operation/UpdateOperationTest.java
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import org.jgrapht.Graph;
import org.jgrapht.graph.ClassBasedEdgeFactory;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
import com.google.common.collect.ImmutableMap;
import eu.drus.jpa.unit.neo4j.dataset.Edge;
import eu.drus.jpa.unit.neo4j.dataset.GraphElementFactory;
import eu.drus.jpa.unit.neo4j.dataset.Node;
import eu.drus.jpa.unit.neo4j.test.entities.A;
import eu.drus.jpa.unit.neo4j.test.entities.B;
package eu.drus.jpa.unit.neo4j.operation;
@RunWith(MockitoJUnitRunner.class)
public class UpdateOperationTest {
private GraphElementFactory graphElementFactory;
@Mock
private Connection connection;
@Spy
private UpdateOperation operation;
@Before
public void prepareMocks() throws SQLException {
doAnswer(i -> null).when(operation).executeQuery(any(Connection.class), anyString());
| graphElementFactory = new GraphElementFactory(Arrays.asList(A.class, B.class)); |
dadrus/jpa-unit | mongodb/src/main/java/eu/drus/jpa/unit/mongodb/MongoDbDecorator.java | // Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/ext/ConfigurationRegistry.java
// public class ConfigurationRegistry {
//
// private static final ServiceLoader<ConfigurationFactory> CONFIG_FACTORIES = ServiceLoader.load(ConfigurationFactory.class);
//
// public boolean hasConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return true;
// }
// }
// return false;
// }
//
// public Configuration getConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return factory.createConfiguration(descriptor);
// }
// }
// throw new JpaUnitException("Unsupported JPA provider");
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
| import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;
import eu.drus.jpa.unit.mongodb.ext.Configuration;
import eu.drus.jpa.unit.mongodb.ext.ConfigurationRegistry;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
import eu.drus.jpa.unit.spi.TestMethodDecorator; | package eu.drus.jpa.unit.mongodb;
public class MongoDbDecorator implements TestMethodDecorator {
private ConfigurationRegistry configurationRegistry = new ConfigurationRegistry();
@Override
public int getPriority() {
return 3;
}
@Override | // Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/ext/ConfigurationRegistry.java
// public class ConfigurationRegistry {
//
// private static final ServiceLoader<ConfigurationFactory> CONFIG_FACTORIES = ServiceLoader.load(ConfigurationFactory.class);
//
// public boolean hasConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return true;
// }
// }
// return false;
// }
//
// public Configuration getConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return factory.createConfiguration(descriptor);
// }
// }
// throw new JpaUnitException("Unsupported JPA provider");
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
// Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/MongoDbDecorator.java
import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;
import eu.drus.jpa.unit.mongodb.ext.Configuration;
import eu.drus.jpa.unit.mongodb.ext.ConfigurationRegistry;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
import eu.drus.jpa.unit.spi.TestMethodDecorator;
package eu.drus.jpa.unit.mongodb;
public class MongoDbDecorator implements TestMethodDecorator {
private ConfigurationRegistry configurationRegistry = new ConfigurationRegistry();
@Override
public int getPriority() {
return 3;
}
@Override | public void beforeTest(final TestInvocation invocation) throws Exception { |
dadrus/jpa-unit | mongodb/src/main/java/eu/drus/jpa/unit/mongodb/MongoDbDecorator.java | // Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/ext/ConfigurationRegistry.java
// public class ConfigurationRegistry {
//
// private static final ServiceLoader<ConfigurationFactory> CONFIG_FACTORIES = ServiceLoader.load(ConfigurationFactory.class);
//
// public boolean hasConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return true;
// }
// }
// return false;
// }
//
// public Configuration getConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return factory.createConfiguration(descriptor);
// }
// }
// throw new JpaUnitException("Unsupported JPA provider");
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
| import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;
import eu.drus.jpa.unit.mongodb.ext.Configuration;
import eu.drus.jpa.unit.mongodb.ext.ConfigurationRegistry;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
import eu.drus.jpa.unit.spi.TestMethodDecorator; | package eu.drus.jpa.unit.mongodb;
public class MongoDbDecorator implements TestMethodDecorator {
private ConfigurationRegistry configurationRegistry = new ConfigurationRegistry();
@Override
public int getPriority() {
return 3;
}
@Override
public void beforeTest(final TestInvocation invocation) throws Exception { | // Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/ext/ConfigurationRegistry.java
// public class ConfigurationRegistry {
//
// private static final ServiceLoader<ConfigurationFactory> CONFIG_FACTORIES = ServiceLoader.load(ConfigurationFactory.class);
//
// public boolean hasConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return true;
// }
// }
// return false;
// }
//
// public Configuration getConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return factory.createConfiguration(descriptor);
// }
// }
// throw new JpaUnitException("Unsupported JPA provider");
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
// Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/MongoDbDecorator.java
import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;
import eu.drus.jpa.unit.mongodb.ext.Configuration;
import eu.drus.jpa.unit.mongodb.ext.ConfigurationRegistry;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
import eu.drus.jpa.unit.spi.TestMethodDecorator;
package eu.drus.jpa.unit.mongodb;
public class MongoDbDecorator implements TestMethodDecorator {
private ConfigurationRegistry configurationRegistry = new ConfigurationRegistry();
@Override
public int getPriority() {
return 3;
}
@Override
public void beforeTest(final TestInvocation invocation) throws Exception { | final ExecutionContext context = invocation.getContext(); |
dadrus/jpa-unit | mongodb/src/main/java/eu/drus/jpa/unit/mongodb/MongoClientDecorator.java | // Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/ext/ConfigurationRegistry.java
// public class ConfigurationRegistry {
//
// private static final ServiceLoader<ConfigurationFactory> CONFIG_FACTORIES = ServiceLoader.load(ConfigurationFactory.class);
//
// public boolean hasConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return true;
// }
// }
// return false;
// }
//
// public Configuration getConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return factory.createConfiguration(descriptor);
// }
// }
// throw new JpaUnitException("Unsupported JPA provider");
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import com.mongodb.MongoClient;
import eu.drus.jpa.unit.mongodb.ext.Configuration;
import eu.drus.jpa.unit.mongodb.ext.ConfigurationRegistry;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestClassDecorator;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.mongodb;
public class MongoClientDecorator implements TestClassDecorator {
private ConfigurationRegistry configurationRegistry = new ConfigurationRegistry();
@Override
public int getPriority() {
return 3;
}
@Override | // Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/ext/ConfigurationRegistry.java
// public class ConfigurationRegistry {
//
// private static final ServiceLoader<ConfigurationFactory> CONFIG_FACTORIES = ServiceLoader.load(ConfigurationFactory.class);
//
// public boolean hasConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return true;
// }
// }
// return false;
// }
//
// public Configuration getConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return factory.createConfiguration(descriptor);
// }
// }
// throw new JpaUnitException("Unsupported JPA provider");
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/MongoClientDecorator.java
import com.mongodb.MongoClient;
import eu.drus.jpa.unit.mongodb.ext.Configuration;
import eu.drus.jpa.unit.mongodb.ext.ConfigurationRegistry;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestClassDecorator;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.mongodb;
public class MongoClientDecorator implements TestClassDecorator {
private ConfigurationRegistry configurationRegistry = new ConfigurationRegistry();
@Override
public int getPriority() {
return 3;
}
@Override | public boolean isConfigurationSupported(final ExecutionContext ctx) { |
dadrus/jpa-unit | mongodb/src/main/java/eu/drus/jpa/unit/mongodb/MongoClientDecorator.java | // Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/ext/ConfigurationRegistry.java
// public class ConfigurationRegistry {
//
// private static final ServiceLoader<ConfigurationFactory> CONFIG_FACTORIES = ServiceLoader.load(ConfigurationFactory.class);
//
// public boolean hasConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return true;
// }
// }
// return false;
// }
//
// public Configuration getConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return factory.createConfiguration(descriptor);
// }
// }
// throw new JpaUnitException("Unsupported JPA provider");
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import com.mongodb.MongoClient;
import eu.drus.jpa.unit.mongodb.ext.Configuration;
import eu.drus.jpa.unit.mongodb.ext.ConfigurationRegistry;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestClassDecorator;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.mongodb;
public class MongoClientDecorator implements TestClassDecorator {
private ConfigurationRegistry configurationRegistry = new ConfigurationRegistry();
@Override
public int getPriority() {
return 3;
}
@Override
public boolean isConfigurationSupported(final ExecutionContext ctx) {
return configurationRegistry.hasConfiguration(ctx.getDescriptor());
}
@Override | // Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/ext/ConfigurationRegistry.java
// public class ConfigurationRegistry {
//
// private static final ServiceLoader<ConfigurationFactory> CONFIG_FACTORIES = ServiceLoader.load(ConfigurationFactory.class);
//
// public boolean hasConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return true;
// }
// }
// return false;
// }
//
// public Configuration getConfiguration(final PersistenceUnitDescriptor descriptor) {
// for (final ConfigurationFactory factory : CONFIG_FACTORIES) {
// if (factory.isSupported(descriptor)) {
// return factory.createConfiguration(descriptor);
// }
// }
// throw new JpaUnitException("Unsupported JPA provider");
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/MongoClientDecorator.java
import com.mongodb.MongoClient;
import eu.drus.jpa.unit.mongodb.ext.Configuration;
import eu.drus.jpa.unit.mongodb.ext.ConfigurationRegistry;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestClassDecorator;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.mongodb;
public class MongoClientDecorator implements TestClassDecorator {
private ConfigurationRegistry configurationRegistry = new ConfigurationRegistry();
@Override
public int getPriority() {
return 3;
}
@Override
public boolean isConfigurationSupported(final ExecutionContext ctx) {
return configurationRegistry.hasConfiguration(ctx.getDescriptor());
}
@Override | public void beforeAll(final TestInvocation invocation) throws Exception { |
dadrus/jpa-unit | junit4-extension/src/main/java/eu/drus/jpa/unit/rule/MethodRuleRegistrar.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
| import java.util.List;
import org.junit.rules.MethodRule;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.ExecutionContext; | package eu.drus.jpa.unit.rule;
public final class MethodRuleRegistrar {
private MethodRuleRegistrar() {}
| // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
// Path: junit4-extension/src/main/java/eu/drus/jpa/unit/rule/MethodRuleRegistrar.java
import java.util.List;
import org.junit.rules.MethodRule;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.ExecutionContext;
package eu.drus.jpa.unit.rule;
public final class MethodRuleRegistrar {
private MethodRuleRegistrar() {}
| public static List<MethodRule> registerRules(final List<MethodRule> rules, final DecoratorExecutor executor, |
dadrus/jpa-unit | junit4-extension/src/main/java/eu/drus/jpa/unit/rule/MethodRuleRegistrar.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
| import java.util.List;
import org.junit.rules.MethodRule;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.ExecutionContext; | package eu.drus.jpa.unit.rule;
public final class MethodRuleRegistrar {
private MethodRuleRegistrar() {}
public static List<MethodRule> registerRules(final List<MethodRule> rules, final DecoratorExecutor executor, | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
// Path: junit4-extension/src/main/java/eu/drus/jpa/unit/rule/MethodRuleRegistrar.java
import java.util.List;
import org.junit.rules.MethodRule;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.ExecutionContext;
package eu.drus.jpa.unit.rule;
public final class MethodRuleRegistrar {
private MethodRuleRegistrar() {}
public static List<MethodRule> registerRules(final List<MethodRule> rules, final DecoratorExecutor executor, | final ExecutionContext ctx) { |
dadrus/jpa-unit | cdi/src/test/java/eu/drus/jpa/unit/cdi/CdiProducerDecoratorTest.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.cdi;
@RunWith(MockitoJUnitRunner.class)
public class CdiProducerDecoratorTest {
@Mock | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: cdi/src/test/java/eu/drus/jpa/unit/cdi/CdiProducerDecoratorTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.cdi;
@RunWith(MockitoJUnitRunner.class)
public class CdiProducerDecoratorTest {
@Mock | private TestInvocation invocation; |
dadrus/jpa-unit | cdi/src/test/java/eu/drus/jpa/unit/cdi/CdiProducerDecoratorTest.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.cdi;
@RunWith(MockitoJUnitRunner.class)
public class CdiProducerDecoratorTest {
@Mock
private TestInvocation invocation;
@Mock
private EntityManager em;
@Mock | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: cdi/src/test/java/eu/drus/jpa/unit/cdi/CdiProducerDecoratorTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.cdi;
@RunWith(MockitoJUnitRunner.class)
public class CdiProducerDecoratorTest {
@Mock
private TestInvocation invocation;
@Mock
private EntityManager em;
@Mock | private ExecutionContext ctx; |
dadrus/jpa-unit | cdi/src/test/java/eu/drus/jpa/unit/cdi/CdiProducerDecoratorTest.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.cdi;
@RunWith(MockitoJUnitRunner.class)
public class CdiProducerDecoratorTest {
@Mock
private TestInvocation invocation;
@Mock
private EntityManager em;
@Mock
private ExecutionContext ctx;
@Mock
private EntityManagerHolder emh;
@InjectMocks
private CdiProducerDecorator fixture;
@Before
public void setUp() throws Exception {
when(invocation.getContext()).thenReturn(ctx); | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: cdi/src/test/java/eu/drus/jpa/unit/cdi/CdiProducerDecoratorTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import javax.persistence.EntityManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.cdi;
@RunWith(MockitoJUnitRunner.class)
public class CdiProducerDecoratorTest {
@Mock
private TestInvocation invocation;
@Mock
private EntityManager em;
@Mock
private ExecutionContext ctx;
@Mock
private EntityManagerHolder emh;
@InjectMocks
private CdiProducerDecorator fixture;
@Before
public void setUp() throws Exception {
when(invocation.getContext()).thenReturn(ctx); | when(ctx.getData(eq(Constants.KEY_ENTITY_MANAGER))).thenReturn(em); |
dadrus/jpa-unit | mongodb/src/main/java/eu/drus/jpa/unit/mongodb/DataSeedStrategyProvider.java | // Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/operation/MongoDbOperations.java
// public final class MongoDbOperations {
// private MongoDbOperations() {}
//
// public static final MongoDbOperation UPDATE = new UpdateOperation();
//
// public static final MongoDbOperation INSERT = new InsertOperation();
//
// public static final MongoDbOperation REFRESH = new RefreshOperation();
//
// public static final MongoDbOperation DELETE = new DeleteOperation();
//
// public static final MongoDbOperation DELETE_ALL = new DeleteAllOperation();
//
// public static final MongoDbOperation CLEAN_INSERT = new CompositeOperation(DELETE_ALL, INSERT);
// }
| import eu.drus.jpa.unit.api.DataSeedStrategy.StrategyProvider;
import eu.drus.jpa.unit.mongodb.operation.MongoDbOperation;
import eu.drus.jpa.unit.mongodb.operation.MongoDbOperations; | package eu.drus.jpa.unit.mongodb;
public class DataSeedStrategyProvider implements StrategyProvider<MongoDbOperation> {
@Override
public MongoDbOperation insertStrategy() { | // Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/operation/MongoDbOperations.java
// public final class MongoDbOperations {
// private MongoDbOperations() {}
//
// public static final MongoDbOperation UPDATE = new UpdateOperation();
//
// public static final MongoDbOperation INSERT = new InsertOperation();
//
// public static final MongoDbOperation REFRESH = new RefreshOperation();
//
// public static final MongoDbOperation DELETE = new DeleteOperation();
//
// public static final MongoDbOperation DELETE_ALL = new DeleteAllOperation();
//
// public static final MongoDbOperation CLEAN_INSERT = new CompositeOperation(DELETE_ALL, INSERT);
// }
// Path: mongodb/src/main/java/eu/drus/jpa/unit/mongodb/DataSeedStrategyProvider.java
import eu.drus.jpa.unit.api.DataSeedStrategy.StrategyProvider;
import eu.drus.jpa.unit.mongodb.operation.MongoDbOperation;
import eu.drus.jpa.unit.mongodb.operation.MongoDbOperations;
package eu.drus.jpa.unit.mongodb;
public class DataSeedStrategyProvider implements StrategyProvider<MongoDbOperation> {
@Override
public MongoDbOperation insertStrategy() { | return MongoDbOperations.INSERT; |
dadrus/jpa-unit | concordion/src/main/java/eu/drus/jpa/unit/concordion/EnhancedProxy.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/util/ReflectionUtils.java
// public final class ReflectionUtils {
// private ReflectionUtils() {}
//
// private static Field findField(final Object src, final String fieldName) throws NoSuchFieldException {
// Class<?> current = src.getClass();
// Field field = null;
//
// while(current != null && field == null) {
// field = getField(current, fieldName);
// current = current.getSuperclass();
// }
//
// if(field == null) {
// throw new NoSuchFieldException(src + " does not declare " + fieldName);
// }
//
// return field;
// }
//
// private static Field getField(Class<?> clazz, final String fieldName) {
// for (Field field : clazz.getDeclaredFields()) {
// if(field.getName().equals(fieldName)) {
// return field;
// }
// }
// return null;
// }
//
// public static void injectValue(final Object obj, final String fieldName, final Object value) throws NoSuchFieldException, IllegalAccessException {
// injectValue(obj, findField(obj, fieldName), value);
// }
//
// public static void injectValue(final Object obj, final Field field, final Object value) throws IllegalAccessException {
// final boolean isAccessible = field.isAccessible();
// field.setAccessible(true);
// try {
// field.set(obj, value);
// } finally {
// field.setAccessible(isAccessible);
// }
// }
//
// public static Object getValue(final Object src, final String fieldName) throws IllegalAccessException, NoSuchFieldException {
// return getValue(src, findField(src, fieldName));
// }
//
// public static Object getValue(final Object src, final Field field) throws IllegalAccessException {
// final boolean isAccessible = field.isAccessible();
// field.setAccessible(true);
// try {
// return field.get(src);
// } finally {
// field.setAccessible(isAccessible);
// }
// }
// }
| import static net.bytebuddy.implementation.MethodDelegation.to;
import static net.bytebuddy.implementation.MethodDelegation.toField;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isClone;
import static net.bytebuddy.matcher.ElementMatchers.isDeclaredBy;
import static net.bytebuddy.matcher.ElementMatchers.isEquals;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
import static net.bytebuddy.matcher.ElementMatchers.not;
import java.lang.reflect.Modifier;
import eu.drus.jpa.unit.api.JpaUnitException;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.util.ReflectionUtils;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy; | package eu.drus.jpa.unit.concordion;
public interface EnhancedProxy {
static Object create(final Object bean, DecoratorExecutor executor) {
try {
Object proxy = new ByteBuddy()
.subclass(bean.getClass())
.implement(EnhancedProxy.class)
.defineField("bean", bean.getClass(), Modifier.PRIVATE)
.defineField("executor", DecoratorExecutor.class, Modifier.PRIVATE)
.method(isEquals())
.intercept(to(EqualsInterceptor.class))
.method(not(isDeclaredBy(Object.class).or(isAnnotatedWith(nameStartsWith("org.concordion.api")))))
.intercept(to(ConcordionInterceptor.class))
.method(isDeclaredBy(Object.class).and(not(isEquals().or(isClone()))))
.intercept(toField("bean"))
.make()
.load(bean.getClass().getClassLoader(), ClassLoadingStrategy.Default.INJECTION)
.getLoaded()
.newInstance();
| // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/util/ReflectionUtils.java
// public final class ReflectionUtils {
// private ReflectionUtils() {}
//
// private static Field findField(final Object src, final String fieldName) throws NoSuchFieldException {
// Class<?> current = src.getClass();
// Field field = null;
//
// while(current != null && field == null) {
// field = getField(current, fieldName);
// current = current.getSuperclass();
// }
//
// if(field == null) {
// throw new NoSuchFieldException(src + " does not declare " + fieldName);
// }
//
// return field;
// }
//
// private static Field getField(Class<?> clazz, final String fieldName) {
// for (Field field : clazz.getDeclaredFields()) {
// if(field.getName().equals(fieldName)) {
// return field;
// }
// }
// return null;
// }
//
// public static void injectValue(final Object obj, final String fieldName, final Object value) throws NoSuchFieldException, IllegalAccessException {
// injectValue(obj, findField(obj, fieldName), value);
// }
//
// public static void injectValue(final Object obj, final Field field, final Object value) throws IllegalAccessException {
// final boolean isAccessible = field.isAccessible();
// field.setAccessible(true);
// try {
// field.set(obj, value);
// } finally {
// field.setAccessible(isAccessible);
// }
// }
//
// public static Object getValue(final Object src, final String fieldName) throws IllegalAccessException, NoSuchFieldException {
// return getValue(src, findField(src, fieldName));
// }
//
// public static Object getValue(final Object src, final Field field) throws IllegalAccessException {
// final boolean isAccessible = field.isAccessible();
// field.setAccessible(true);
// try {
// return field.get(src);
// } finally {
// field.setAccessible(isAccessible);
// }
// }
// }
// Path: concordion/src/main/java/eu/drus/jpa/unit/concordion/EnhancedProxy.java
import static net.bytebuddy.implementation.MethodDelegation.to;
import static net.bytebuddy.implementation.MethodDelegation.toField;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isClone;
import static net.bytebuddy.matcher.ElementMatchers.isDeclaredBy;
import static net.bytebuddy.matcher.ElementMatchers.isEquals;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
import static net.bytebuddy.matcher.ElementMatchers.not;
import java.lang.reflect.Modifier;
import eu.drus.jpa.unit.api.JpaUnitException;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.util.ReflectionUtils;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
package eu.drus.jpa.unit.concordion;
public interface EnhancedProxy {
static Object create(final Object bean, DecoratorExecutor executor) {
try {
Object proxy = new ByteBuddy()
.subclass(bean.getClass())
.implement(EnhancedProxy.class)
.defineField("bean", bean.getClass(), Modifier.PRIVATE)
.defineField("executor", DecoratorExecutor.class, Modifier.PRIVATE)
.method(isEquals())
.intercept(to(EqualsInterceptor.class))
.method(not(isDeclaredBy(Object.class).or(isAnnotatedWith(nameStartsWith("org.concordion.api")))))
.intercept(to(ConcordionInterceptor.class))
.method(isDeclaredBy(Object.class).and(not(isEquals().or(isClone()))))
.intercept(toField("bean"))
.make()
.load(bean.getClass().getClassLoader(), ClassLoadingStrategy.Default.INJECTION)
.getLoaded()
.newInstance();
| ReflectionUtils.injectValue(proxy, "bean", bean); |
dadrus/jpa-unit | core/src/main/java/eu/drus/jpa/unit/decorator/jpa/SecondLevelCacheDecorator.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import javax.persistence.EntityManagerFactory;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestMethodDecorator;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.decorator.jpa;
public class SecondLevelCacheDecorator implements TestMethodDecorator {
@Override
public int getPriority() {
return 0;
}
private void evictCache(final boolean doEvict, final EntityManagerFactory emf) {
if (doEvict) {
emf.getCache().evictAll();
}
}
@Override | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: core/src/main/java/eu/drus/jpa/unit/decorator/jpa/SecondLevelCacheDecorator.java
import javax.persistence.EntityManagerFactory;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestMethodDecorator;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.decorator.jpa;
public class SecondLevelCacheDecorator implements TestMethodDecorator {
@Override
public int getPriority() {
return 0;
}
private void evictCache(final boolean doEvict, final EntityManagerFactory emf) {
if (doEvict) {
emf.getCache().evictAll();
}
}
@Override | public void beforeTest(final TestInvocation invocation) throws Exception { |
dadrus/jpa-unit | core/src/main/java/eu/drus/jpa/unit/decorator/jpa/SecondLevelCacheDecorator.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import javax.persistence.EntityManagerFactory;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestMethodDecorator;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.decorator.jpa;
public class SecondLevelCacheDecorator implements TestMethodDecorator {
@Override
public int getPriority() {
return 0;
}
private void evictCache(final boolean doEvict, final EntityManagerFactory emf) {
if (doEvict) {
emf.getCache().evictAll();
}
}
@Override
public void beforeTest(final TestInvocation invocation) throws Exception { | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: core/src/main/java/eu/drus/jpa/unit/decorator/jpa/SecondLevelCacheDecorator.java
import javax.persistence.EntityManagerFactory;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestMethodDecorator;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.decorator.jpa;
public class SecondLevelCacheDecorator implements TestMethodDecorator {
@Override
public int getPriority() {
return 0;
}
private void evictCache(final boolean doEvict, final EntityManagerFactory emf) {
if (doEvict) {
emf.getCache().evictAll();
}
}
@Override
public void beforeTest(final TestInvocation invocation) throws Exception { | final EntityManagerFactory emf = (EntityManagerFactory) invocation.getContext().getData(Constants.KEY_ENTITY_MANAGER_FACTORY); |
dadrus/jpa-unit | core/src/main/java/eu/drus/jpa/unit/decorator/jpa/SecondLevelCacheDecorator.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import javax.persistence.EntityManagerFactory;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestMethodDecorator;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.decorator.jpa;
public class SecondLevelCacheDecorator implements TestMethodDecorator {
@Override
public int getPriority() {
return 0;
}
private void evictCache(final boolean doEvict, final EntityManagerFactory emf) {
if (doEvict) {
emf.getCache().evictAll();
}
}
@Override
public void beforeTest(final TestInvocation invocation) throws Exception {
final EntityManagerFactory emf = (EntityManagerFactory) invocation.getContext().getData(Constants.KEY_ENTITY_MANAGER_FACTORY);
evictCache(invocation.getFeatureResolver().shouldEvictCacheBefore(), emf);
}
@Override
public void afterTest(final TestInvocation invocation) throws Exception {
final EntityManagerFactory emf = (EntityManagerFactory) invocation.getContext().getData(Constants.KEY_ENTITY_MANAGER_FACTORY);
evictCache(invocation.getFeatureResolver().shouldEvictCacheAfter(), emf);
}
@Override | // Path: core/src/main/java/eu/drus/jpa/unit/spi/Constants.java
// public final class Constants {
//
// private Constants() {}
//
// public static final String KEY_ENTITY_MANAGER_FACTORY = "eu.drus.jpa.unit.core.EntityManagerFactory";
// public static final String KEY_ENTITY_MANAGER = "eu.drus.jpa.unit.core.EntityManager";
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: core/src/main/java/eu/drus/jpa/unit/decorator/jpa/SecondLevelCacheDecorator.java
import javax.persistence.EntityManagerFactory;
import eu.drus.jpa.unit.spi.Constants;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestMethodDecorator;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.decorator.jpa;
public class SecondLevelCacheDecorator implements TestMethodDecorator {
@Override
public int getPriority() {
return 0;
}
private void evictCache(final boolean doEvict, final EntityManagerFactory emf) {
if (doEvict) {
emf.getCache().evictAll();
}
}
@Override
public void beforeTest(final TestInvocation invocation) throws Exception {
final EntityManagerFactory emf = (EntityManagerFactory) invocation.getContext().getData(Constants.KEY_ENTITY_MANAGER_FACTORY);
evictCache(invocation.getFeatureResolver().shouldEvictCacheBefore(), emf);
}
@Override
public void afterTest(final TestInvocation invocation) throws Exception {
final EntityManagerFactory emf = (EntityManagerFactory) invocation.getContext().getData(Constants.KEY_ENTITY_MANAGER_FACTORY);
evictCache(invocation.getFeatureResolver().shouldEvictCacheAfter(), emf);
}
@Override | public boolean isConfigurationSupported(final ExecutionContext ctx) { |
dadrus/jpa-unit | core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java | // Path: core/src/main/java/eu/drus/jpa/unit/core/DecoratorRegistrar.java
// public static List<TestClassDecorator> getClassDecorators() {
// final List<TestClassDecorator> decorators = new ArrayList<>();
// CLASS_DECORATORS.iterator().forEachRemaining(decorators::add);
// return decorators;
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/core/DecoratorRegistrar.java
// public static List<TestMethodDecorator> getMethodDecorators() {
// final List<TestMethodDecorator> decorators = new ArrayList<>();
// METHOD_DECORATORS.iterator().forEachRemaining(decorators::add);
// return decorators;
// }
| import static eu.drus.jpa.unit.core.DecoratorRegistrar.getClassDecorators;
import static eu.drus.jpa.unit.core.DecoratorRegistrar.getMethodDecorators;
import java.util.Comparator;
import java.util.Iterator; | package eu.drus.jpa.unit.spi;
public class DecoratorExecutor {
private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
public void processBeforeAll(final TestInvocation invocation) throws Exception {
final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
while (it.hasNext()) {
it.next().beforeAll(invocation);
}
}
public void processAfterAll(final TestInvocation invocation) throws Exception {
final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
while (it.hasNext()) {
it.next().afterAll(invocation);
}
}
public void processBefore(final TestInvocation invocation) throws Exception {
final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
while (it.hasNext()) {
it.next().beforeTest(invocation);
}
}
public void processAfter(final TestInvocation invocation) throws Exception {
final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
while (it.hasNext()) {
it.next().afterTest(invocation);
}
}
private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) { | // Path: core/src/main/java/eu/drus/jpa/unit/core/DecoratorRegistrar.java
// public static List<TestClassDecorator> getClassDecorators() {
// final List<TestClassDecorator> decorators = new ArrayList<>();
// CLASS_DECORATORS.iterator().forEachRemaining(decorators::add);
// return decorators;
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/core/DecoratorRegistrar.java
// public static List<TestMethodDecorator> getMethodDecorators() {
// final List<TestMethodDecorator> decorators = new ArrayList<>();
// METHOD_DECORATORS.iterator().forEachRemaining(decorators::add);
// return decorators;
// }
// Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
import static eu.drus.jpa.unit.core.DecoratorRegistrar.getClassDecorators;
import static eu.drus.jpa.unit.core.DecoratorRegistrar.getMethodDecorators;
import java.util.Comparator;
import java.util.Iterator;
package eu.drus.jpa.unit.spi;
public class DecoratorExecutor {
private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
public void processBeforeAll(final TestInvocation invocation) throws Exception {
final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
while (it.hasNext()) {
it.next().beforeAll(invocation);
}
}
public void processAfterAll(final TestInvocation invocation) throws Exception {
final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
while (it.hasNext()) {
it.next().afterAll(invocation);
}
}
public void processBefore(final TestInvocation invocation) throws Exception {
final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
while (it.hasNext()) {
it.next().beforeTest(invocation);
}
}
public void processAfter(final TestInvocation invocation) throws Exception {
final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
while (it.hasNext()) {
it.next().afterTest(invocation);
}
}
private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) { | return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator(); |
dadrus/jpa-unit | core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java | // Path: core/src/main/java/eu/drus/jpa/unit/core/DecoratorRegistrar.java
// public static List<TestClassDecorator> getClassDecorators() {
// final List<TestClassDecorator> decorators = new ArrayList<>();
// CLASS_DECORATORS.iterator().forEachRemaining(decorators::add);
// return decorators;
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/core/DecoratorRegistrar.java
// public static List<TestMethodDecorator> getMethodDecorators() {
// final List<TestMethodDecorator> decorators = new ArrayList<>();
// METHOD_DECORATORS.iterator().forEachRemaining(decorators::add);
// return decorators;
// }
| import static eu.drus.jpa.unit.core.DecoratorRegistrar.getClassDecorators;
import static eu.drus.jpa.unit.core.DecoratorRegistrar.getMethodDecorators;
import java.util.Comparator;
import java.util.Iterator; | it.next().beforeAll(invocation);
}
}
public void processAfterAll(final TestInvocation invocation) throws Exception {
final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
while (it.hasNext()) {
it.next().afterAll(invocation);
}
}
public void processBefore(final TestInvocation invocation) throws Exception {
final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
while (it.hasNext()) {
it.next().beforeTest(invocation);
}
}
public void processAfter(final TestInvocation invocation) throws Exception {
final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
while (it.hasNext()) {
it.next().afterTest(invocation);
}
}
private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
}
private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) { | // Path: core/src/main/java/eu/drus/jpa/unit/core/DecoratorRegistrar.java
// public static List<TestClassDecorator> getClassDecorators() {
// final List<TestClassDecorator> decorators = new ArrayList<>();
// CLASS_DECORATORS.iterator().forEachRemaining(decorators::add);
// return decorators;
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/core/DecoratorRegistrar.java
// public static List<TestMethodDecorator> getMethodDecorators() {
// final List<TestMethodDecorator> decorators = new ArrayList<>();
// METHOD_DECORATORS.iterator().forEachRemaining(decorators::add);
// return decorators;
// }
// Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
import static eu.drus.jpa.unit.core.DecoratorRegistrar.getClassDecorators;
import static eu.drus.jpa.unit.core.DecoratorRegistrar.getMethodDecorators;
import java.util.Comparator;
import java.util.Iterator;
it.next().beforeAll(invocation);
}
}
public void processAfterAll(final TestInvocation invocation) throws Exception {
final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
while (it.hasNext()) {
it.next().afterAll(invocation);
}
}
public void processBefore(final TestInvocation invocation) throws Exception {
final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
while (it.hasNext()) {
it.next().beforeTest(invocation);
}
}
public void processAfter(final TestInvocation invocation) throws Exception {
final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
while (it.hasNext()) {
it.next().afterTest(invocation);
}
}
private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
}
private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) { | return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator(); |
dadrus/jpa-unit | rdbms/src/main/java/eu/drus/jpa/unit/sql/BootstrappingDecorator.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static com.google.common.base.Preconditions.checkArgument;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import javax.sql.DataSource;
import eu.drus.jpa.unit.core.metadata.MetadataExtractor;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestClassDecorator;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.sql;
public class BootstrappingDecorator implements TestClassDecorator {
@Override
public int getPriority() {
return 1;
}
@Override | // Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: rdbms/src/main/java/eu/drus/jpa/unit/sql/BootstrappingDecorator.java
import static com.google.common.base.Preconditions.checkArgument;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import javax.sql.DataSource;
import eu.drus.jpa.unit.core.metadata.MetadataExtractor;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestClassDecorator;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.sql;
public class BootstrappingDecorator implements TestClassDecorator {
@Override
public int getPriority() {
return 1;
}
@Override | public void beforeAll(final TestInvocation invocation) throws Exception { |
dadrus/jpa-unit | rdbms/src/main/java/eu/drus/jpa/unit/sql/BootstrappingDecorator.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static com.google.common.base.Preconditions.checkArgument;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import javax.sql.DataSource;
import eu.drus.jpa.unit.core.metadata.MetadataExtractor;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestClassDecorator;
import eu.drus.jpa.unit.spi.TestInvocation; | package eu.drus.jpa.unit.sql;
public class BootstrappingDecorator implements TestClassDecorator {
@Override
public int getPriority() {
return 1;
}
@Override
public void beforeAll(final TestInvocation invocation) throws Exception {
final DataSource ds = (DataSource) invocation.getContext().getData(Constants.KEY_DATA_SOURCE);
final MetadataExtractor extractor = new MetadataExtractor(invocation.getTestClass());
final List<Method> bootstrappingMethods = extractor.bootstrapping().getAnnotatedMethods();
checkArgument(bootstrappingMethods.size() <= 1, "Only single method is allowed to be annotated with @Bootstrapping");
if (!bootstrappingMethods.isEmpty()) {
final Method tmp = bootstrappingMethods.get(0);
checkArgument(Modifier.isStatic(tmp.getModifiers()), "A bootstrapping method is required to be static");
final Class<?>[] parameterTypes = tmp.getParameterTypes();
checkArgument(parameterTypes.length == 1, "A bootstrapping method is required to have a single parameter of type DataSource");
checkArgument(parameterTypes[0].equals(DataSource.class),
"A bootstrapping method is required to have a single parameter of type DataSource");
tmp.invoke(null, ds);
}
}
@Override
public void afterAll(final TestInvocation invocation) throws Exception {
// nothing to do here
}
@Override | // Path: core/src/main/java/eu/drus/jpa/unit/spi/ExecutionContext.java
// public interface ExecutionContext {
//
// Field getPersistenceField();
//
// PersistenceUnitDescriptor getDescriptor();
//
// void storeData(String key, Object value);
//
// Object getData(String key);
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: rdbms/src/main/java/eu/drus/jpa/unit/sql/BootstrappingDecorator.java
import static com.google.common.base.Preconditions.checkArgument;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import javax.sql.DataSource;
import eu.drus.jpa.unit.core.metadata.MetadataExtractor;
import eu.drus.jpa.unit.spi.ExecutionContext;
import eu.drus.jpa.unit.spi.TestClassDecorator;
import eu.drus.jpa.unit.spi.TestInvocation;
package eu.drus.jpa.unit.sql;
public class BootstrappingDecorator implements TestClassDecorator {
@Override
public int getPriority() {
return 1;
}
@Override
public void beforeAll(final TestInvocation invocation) throws Exception {
final DataSource ds = (DataSource) invocation.getContext().getData(Constants.KEY_DATA_SOURCE);
final MetadataExtractor extractor = new MetadataExtractor(invocation.getTestClass());
final List<Method> bootstrappingMethods = extractor.bootstrapping().getAnnotatedMethods();
checkArgument(bootstrappingMethods.size() <= 1, "Only single method is allowed to be annotated with @Bootstrapping");
if (!bootstrappingMethods.isEmpty()) {
final Method tmp = bootstrappingMethods.get(0);
checkArgument(Modifier.isStatic(tmp.getModifiers()), "A bootstrapping method is required to be static");
final Class<?>[] parameterTypes = tmp.getParameterTypes();
checkArgument(parameterTypes.length == 1, "A bootstrapping method is required to have a single parameter of type DataSource");
checkArgument(parameterTypes[0].equals(DataSource.class),
"A bootstrapping method is required to have a single parameter of type DataSource");
tmp.invoke(null, ds);
}
}
@Override
public void afterAll(final TestInvocation invocation) throws Exception {
// nothing to do here
}
@Override | public boolean isConfigurationSupported(final ExecutionContext ctx) { |
dadrus/jpa-unit | integration-test/base/src/main/java/eu/drus/jpa/unit/test/AbstractCleanupUsingScriptTest.java | // Path: mongodb/src/integrationtest/java/eu/drus/jpa/unit/test/model/ContactType.java
// public enum ContactType {
// TELEPHONE,
// MOBILE,
// FAX,
// EMAIL
// }
//
// Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/Depositor.java
// @Entity
// @Table(name = "DEPOSITOR")
// public class Depositor {
//
// // persistence specific attributes
//
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private Long id;
//
// @Version
// @Column(name = "VERSION")
// private Long version;
//
// // entity attributes
//
// @Column(name = "NAME")
// @Basic(optional = false)
// private String name;
//
// @Column(name = "SURNAME")
// @Basic(optional = false)
// private String surname;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<Address> addresses = new HashSet<>();
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<ContactDetail> contactDetails = new HashSet<>();
//
// @OneToMany(mappedBy = "depositor", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Account> accounts = new HashSet<>();
//
// protected Depositor() {
// // for JPA
// }
//
// public Depositor(final String name, final String surname) {
// this.name = name;
// this.surname = surname;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public String getSurname() {
// return surname;
// }
//
// public void setSurname(final String surname) {
// this.surname = surname;
// }
//
// public Set<Account> getAccounts() {
// return Collections.unmodifiableSet(accounts);
// }
//
// protected boolean addAccount(final Account account) {
// return accounts.add(account);
// }
//
// public boolean removeAccount(final Account account) {
// if (accounts.remove(account)) {
// account.setDepositor(null);
// return true;
// }
// return false;
// }
//
// public boolean addAddress(final Address address) {
// return addresses.add(address);
// }
//
// public boolean removeAddress(final Address address) {
// return addresses.remove(address);
// }
//
// public Set<Address> getAddresses() {
// return Collections.unmodifiableSet(addresses);
// }
//
// public Set<ContactDetail> getContactDetails() {
// return Collections.unmodifiableSet(contactDetails);
// }
//
// public boolean addContactDetail(final ContactDetail contactDetail) {
// return contactDetails.add(contactDetail);
// }
//
// public boolean removeContactDetail(final ContactDetail contactDetail) {
// return contactDetails.remove(contactDetail);
// }
//
// @Override
// public String toString() {
// final ToStringBuilder builder = new ToStringBuilder(this);
// builder.append("id", id);
// builder.append("version", version);
// builder.append("name", name);
// builder.append("surname", surname);
// return builder.build();
// }
// }
| import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import eu.drus.jpa.unit.api.Cleanup;
import eu.drus.jpa.unit.api.CleanupPhase;
import eu.drus.jpa.unit.api.CleanupUsingScripts;
import eu.drus.jpa.unit.test.model.Address;
import eu.drus.jpa.unit.test.model.ContactDetail;
import eu.drus.jpa.unit.test.model.ContactType;
import eu.drus.jpa.unit.test.model.Depositor;
import eu.drus.jpa.unit.test.model.GiroAccount;
import eu.drus.jpa.unit.test.model.OperationNotSupportedException; | package eu.drus.jpa.unit.test;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Cleanup(phase = CleanupPhase.NONE)
public abstract class AbstractCleanupUsingScriptTest {
@PersistenceContext(unitName = "my-test-unit")
private EntityManager manager;
@Test
public void test1() throws OperationNotSupportedException {
// just seed the DB with some data | // Path: mongodb/src/integrationtest/java/eu/drus/jpa/unit/test/model/ContactType.java
// public enum ContactType {
// TELEPHONE,
// MOBILE,
// FAX,
// EMAIL
// }
//
// Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/Depositor.java
// @Entity
// @Table(name = "DEPOSITOR")
// public class Depositor {
//
// // persistence specific attributes
//
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private Long id;
//
// @Version
// @Column(name = "VERSION")
// private Long version;
//
// // entity attributes
//
// @Column(name = "NAME")
// @Basic(optional = false)
// private String name;
//
// @Column(name = "SURNAME")
// @Basic(optional = false)
// private String surname;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<Address> addresses = new HashSet<>();
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<ContactDetail> contactDetails = new HashSet<>();
//
// @OneToMany(mappedBy = "depositor", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Account> accounts = new HashSet<>();
//
// protected Depositor() {
// // for JPA
// }
//
// public Depositor(final String name, final String surname) {
// this.name = name;
// this.surname = surname;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public String getSurname() {
// return surname;
// }
//
// public void setSurname(final String surname) {
// this.surname = surname;
// }
//
// public Set<Account> getAccounts() {
// return Collections.unmodifiableSet(accounts);
// }
//
// protected boolean addAccount(final Account account) {
// return accounts.add(account);
// }
//
// public boolean removeAccount(final Account account) {
// if (accounts.remove(account)) {
// account.setDepositor(null);
// return true;
// }
// return false;
// }
//
// public boolean addAddress(final Address address) {
// return addresses.add(address);
// }
//
// public boolean removeAddress(final Address address) {
// return addresses.remove(address);
// }
//
// public Set<Address> getAddresses() {
// return Collections.unmodifiableSet(addresses);
// }
//
// public Set<ContactDetail> getContactDetails() {
// return Collections.unmodifiableSet(contactDetails);
// }
//
// public boolean addContactDetail(final ContactDetail contactDetail) {
// return contactDetails.add(contactDetail);
// }
//
// public boolean removeContactDetail(final ContactDetail contactDetail) {
// return contactDetails.remove(contactDetail);
// }
//
// @Override
// public String toString() {
// final ToStringBuilder builder = new ToStringBuilder(this);
// builder.append("id", id);
// builder.append("version", version);
// builder.append("name", name);
// builder.append("surname", surname);
// return builder.build();
// }
// }
// Path: integration-test/base/src/main/java/eu/drus/jpa/unit/test/AbstractCleanupUsingScriptTest.java
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import eu.drus.jpa.unit.api.Cleanup;
import eu.drus.jpa.unit.api.CleanupPhase;
import eu.drus.jpa.unit.api.CleanupUsingScripts;
import eu.drus.jpa.unit.test.model.Address;
import eu.drus.jpa.unit.test.model.ContactDetail;
import eu.drus.jpa.unit.test.model.ContactType;
import eu.drus.jpa.unit.test.model.Depositor;
import eu.drus.jpa.unit.test.model.GiroAccount;
import eu.drus.jpa.unit.test.model.OperationNotSupportedException;
package eu.drus.jpa.unit.test;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Cleanup(phase = CleanupPhase.NONE)
public abstract class AbstractCleanupUsingScriptTest {
@PersistenceContext(unitName = "my-test-unit")
private EntityManager manager;
@Test
public void test1() throws OperationNotSupportedException {
// just seed the DB with some data | final Depositor depositor = new Depositor("Max", "Payne"); |
dadrus/jpa-unit | integration-test/base/src/main/java/eu/drus/jpa/unit/test/AbstractCleanupUsingScriptTest.java | // Path: mongodb/src/integrationtest/java/eu/drus/jpa/unit/test/model/ContactType.java
// public enum ContactType {
// TELEPHONE,
// MOBILE,
// FAX,
// EMAIL
// }
//
// Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/Depositor.java
// @Entity
// @Table(name = "DEPOSITOR")
// public class Depositor {
//
// // persistence specific attributes
//
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private Long id;
//
// @Version
// @Column(name = "VERSION")
// private Long version;
//
// // entity attributes
//
// @Column(name = "NAME")
// @Basic(optional = false)
// private String name;
//
// @Column(name = "SURNAME")
// @Basic(optional = false)
// private String surname;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<Address> addresses = new HashSet<>();
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<ContactDetail> contactDetails = new HashSet<>();
//
// @OneToMany(mappedBy = "depositor", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Account> accounts = new HashSet<>();
//
// protected Depositor() {
// // for JPA
// }
//
// public Depositor(final String name, final String surname) {
// this.name = name;
// this.surname = surname;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public String getSurname() {
// return surname;
// }
//
// public void setSurname(final String surname) {
// this.surname = surname;
// }
//
// public Set<Account> getAccounts() {
// return Collections.unmodifiableSet(accounts);
// }
//
// protected boolean addAccount(final Account account) {
// return accounts.add(account);
// }
//
// public boolean removeAccount(final Account account) {
// if (accounts.remove(account)) {
// account.setDepositor(null);
// return true;
// }
// return false;
// }
//
// public boolean addAddress(final Address address) {
// return addresses.add(address);
// }
//
// public boolean removeAddress(final Address address) {
// return addresses.remove(address);
// }
//
// public Set<Address> getAddresses() {
// return Collections.unmodifiableSet(addresses);
// }
//
// public Set<ContactDetail> getContactDetails() {
// return Collections.unmodifiableSet(contactDetails);
// }
//
// public boolean addContactDetail(final ContactDetail contactDetail) {
// return contactDetails.add(contactDetail);
// }
//
// public boolean removeContactDetail(final ContactDetail contactDetail) {
// return contactDetails.remove(contactDetail);
// }
//
// @Override
// public String toString() {
// final ToStringBuilder builder = new ToStringBuilder(this);
// builder.append("id", id);
// builder.append("version", version);
// builder.append("name", name);
// builder.append("surname", surname);
// return builder.build();
// }
// }
| import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import eu.drus.jpa.unit.api.Cleanup;
import eu.drus.jpa.unit.api.CleanupPhase;
import eu.drus.jpa.unit.api.CleanupUsingScripts;
import eu.drus.jpa.unit.test.model.Address;
import eu.drus.jpa.unit.test.model.ContactDetail;
import eu.drus.jpa.unit.test.model.ContactType;
import eu.drus.jpa.unit.test.model.Depositor;
import eu.drus.jpa.unit.test.model.GiroAccount;
import eu.drus.jpa.unit.test.model.OperationNotSupportedException; | package eu.drus.jpa.unit.test;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Cleanup(phase = CleanupPhase.NONE)
public abstract class AbstractCleanupUsingScriptTest {
@PersistenceContext(unitName = "my-test-unit")
private EntityManager manager;
@Test
public void test1() throws OperationNotSupportedException {
// just seed the DB with some data
final Depositor depositor = new Depositor("Max", "Payne");
depositor.addAddress(new Address("Unknown", "111111", "Unknown", "Unknown")); | // Path: mongodb/src/integrationtest/java/eu/drus/jpa/unit/test/model/ContactType.java
// public enum ContactType {
// TELEPHONE,
// MOBILE,
// FAX,
// EMAIL
// }
//
// Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/Depositor.java
// @Entity
// @Table(name = "DEPOSITOR")
// public class Depositor {
//
// // persistence specific attributes
//
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private Long id;
//
// @Version
// @Column(name = "VERSION")
// private Long version;
//
// // entity attributes
//
// @Column(name = "NAME")
// @Basic(optional = false)
// private String name;
//
// @Column(name = "SURNAME")
// @Basic(optional = false)
// private String surname;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<Address> addresses = new HashSet<>();
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<ContactDetail> contactDetails = new HashSet<>();
//
// @OneToMany(mappedBy = "depositor", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Account> accounts = new HashSet<>();
//
// protected Depositor() {
// // for JPA
// }
//
// public Depositor(final String name, final String surname) {
// this.name = name;
// this.surname = surname;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public String getSurname() {
// return surname;
// }
//
// public void setSurname(final String surname) {
// this.surname = surname;
// }
//
// public Set<Account> getAccounts() {
// return Collections.unmodifiableSet(accounts);
// }
//
// protected boolean addAccount(final Account account) {
// return accounts.add(account);
// }
//
// public boolean removeAccount(final Account account) {
// if (accounts.remove(account)) {
// account.setDepositor(null);
// return true;
// }
// return false;
// }
//
// public boolean addAddress(final Address address) {
// return addresses.add(address);
// }
//
// public boolean removeAddress(final Address address) {
// return addresses.remove(address);
// }
//
// public Set<Address> getAddresses() {
// return Collections.unmodifiableSet(addresses);
// }
//
// public Set<ContactDetail> getContactDetails() {
// return Collections.unmodifiableSet(contactDetails);
// }
//
// public boolean addContactDetail(final ContactDetail contactDetail) {
// return contactDetails.add(contactDetail);
// }
//
// public boolean removeContactDetail(final ContactDetail contactDetail) {
// return contactDetails.remove(contactDetail);
// }
//
// @Override
// public String toString() {
// final ToStringBuilder builder = new ToStringBuilder(this);
// builder.append("id", id);
// builder.append("version", version);
// builder.append("name", name);
// builder.append("surname", surname);
// return builder.build();
// }
// }
// Path: integration-test/base/src/main/java/eu/drus/jpa/unit/test/AbstractCleanupUsingScriptTest.java
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import eu.drus.jpa.unit.api.Cleanup;
import eu.drus.jpa.unit.api.CleanupPhase;
import eu.drus.jpa.unit.api.CleanupUsingScripts;
import eu.drus.jpa.unit.test.model.Address;
import eu.drus.jpa.unit.test.model.ContactDetail;
import eu.drus.jpa.unit.test.model.ContactType;
import eu.drus.jpa.unit.test.model.Depositor;
import eu.drus.jpa.unit.test.model.GiroAccount;
import eu.drus.jpa.unit.test.model.OperationNotSupportedException;
package eu.drus.jpa.unit.test;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Cleanup(phase = CleanupPhase.NONE)
public abstract class AbstractCleanupUsingScriptTest {
@PersistenceContext(unitName = "my-test-unit")
private EntityManager manager;
@Test
public void test1() throws OperationNotSupportedException {
// just seed the DB with some data
final Depositor depositor = new Depositor("Max", "Payne");
depositor.addAddress(new Address("Unknown", "111111", "Unknown", "Unknown")); | depositor.addContactDetail(new ContactDetail(ContactType.EMAIL, "max@payne.com")); |
dadrus/jpa-unit | cdi/src/integrationtest/java/eu/drus/jpa/unit/test/CdiWithJpaIT.java | // Path: cdi/src/integrationtest/java/eu/drus/jpa/unit/test/model/TestObjectRepository.java
// @Repository
// public interface TestObjectRepository extends EntityRepository<TestObject, Long> {}
| import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import eu.drus.jpa.unit.test.model.TestObjectRepository; | package eu.drus.jpa.unit.test;
/**
* This test verifies that a regular CDI test, which uses JPA functionality without JPA-Unit works
* as expected (no side effects from JPA-Unit)
*
*/
@RunWith(CdiTestRunner.class)
public class CdiWithJpaIT {
@Inject | // Path: cdi/src/integrationtest/java/eu/drus/jpa/unit/test/model/TestObjectRepository.java
// @Repository
// public interface TestObjectRepository extends EntityRepository<TestObject, Long> {}
// Path: cdi/src/integrationtest/java/eu/drus/jpa/unit/test/CdiWithJpaIT.java
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import eu.drus.jpa.unit.test.model.TestObjectRepository;
package eu.drus.jpa.unit.test;
/**
* This test verifies that a regular CDI test, which uses JPA functionality without JPA-Unit works
* as expected (no side effects from JPA-Unit)
*
*/
@RunWith(CdiTestRunner.class)
public class CdiWithJpaIT {
@Inject | private TestObjectRepository repository; |
dadrus/jpa-unit | cucumber/src/test/java/cucumber/runtime/java/jpa/unit/JpaUnitObjectFactoryTest.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.notNull;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import cucumber.api.java.en.Then;
import cucumber.api.java.ru.Если;
import eu.drus.jpa.unit.core.JpaUnitContext;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.TestInvocation; | package cucumber.runtime.java.jpa.unit;
@RunWith(PowerMockRunner.class)
@PrepareForTest(JpaUnitContext.class)
public class JpaUnitObjectFactoryTest {
@Mock
private JpaUnitContext ctx;
@Mock | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: cucumber/src/test/java/cucumber/runtime/java/jpa/unit/JpaUnitObjectFactoryTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.notNull;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import cucumber.api.java.en.Then;
import cucumber.api.java.ru.Если;
import eu.drus.jpa.unit.core.JpaUnitContext;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.TestInvocation;
package cucumber.runtime.java.jpa.unit;
@RunWith(PowerMockRunner.class)
@PrepareForTest(JpaUnitContext.class)
public class JpaUnitObjectFactoryTest {
@Mock
private JpaUnitContext ctx;
@Mock | private DecoratorExecutor executor; |
dadrus/jpa-unit | cucumber/src/test/java/cucumber/runtime/java/jpa/unit/JpaUnitObjectFactoryTest.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.notNull;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import cucumber.api.java.en.Then;
import cucumber.api.java.ru.Если;
import eu.drus.jpa.unit.core.JpaUnitContext;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.TestInvocation; | // THEN
verifyZeroInteractions(executor);
}
@Test
public void testGetInstanceForSameTypeAlwaysReturnsSameObject() {
// GIVEN
// WHEN
final ClassA obj1 = factory.getInstance(ClassA.class);
final ClassA obj2 = factory.getInstance(ClassA.class);
// THEN
assertNotNull(obj1);
assertNotNull(obj2);
assertThat(obj1, equalTo(obj2));
}
@Test
public void testGetInstanceForSameTypeLeadsToExecutionOfProcessBeforeAllOnlyOnce() throws Exception {
// GIVEN
// WHEN
final ClassA obj1 = factory.getInstance(ClassA.class);
final ClassA obj2 = factory.getInstance(ClassA.class);
// THEN
assertNotNull(obj1);
assertNotNull(obj2);
| // Path: core/src/main/java/eu/drus/jpa/unit/spi/DecoratorExecutor.java
// public class DecoratorExecutor {
//
// private static final Comparator<TestDecorator> BEFORE_COMPARATOR = (a, b) -> a.getPriority() - b.getPriority();
// private static final Comparator<TestDecorator> AFTER_COMPARATOR = (a, b) -> b.getPriority() - a.getPriority();
//
// public void processBeforeAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeAll(invocation);
// }
// }
//
// public void processAfterAll(final TestInvocation invocation) throws Exception {
// final Iterator<TestClassDecorator> it = classDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterAll(invocation);
// }
// }
//
// public void processBefore(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), BEFORE_COMPARATOR);
// while (it.hasNext()) {
// it.next().beforeTest(invocation);
// }
// }
//
// public void processAfter(final TestInvocation invocation) throws Exception {
// final Iterator<TestMethodDecorator> it = methodDecoratorIterator(invocation.getContext(), AFTER_COMPARATOR);
// while (it.hasNext()) {
// it.next().afterTest(invocation);
// }
// }
//
// private Iterator<TestClassDecorator> classDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getClassDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
//
// private Iterator<TestMethodDecorator> methodDecoratorIterator(final ExecutionContext ctx, final Comparator<TestDecorator> comparator) {
// return getMethodDecorators().stream().filter(d -> d.isConfigurationSupported(ctx)).sorted(comparator).iterator();
// }
// }
//
// Path: core/src/main/java/eu/drus/jpa/unit/spi/TestInvocation.java
// public interface TestInvocation {
//
// Class<?> getTestClass();
//
// ExecutionContext getContext();
//
// Optional<Method> getTestMethod();
//
// Optional<Object> getTestInstance();
//
// Optional<Throwable> getException();
//
// FeatureResolver getFeatureResolver();
// }
// Path: cucumber/src/test/java/cucumber/runtime/java/jpa/unit/JpaUnitObjectFactoryTest.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.notNull;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import cucumber.api.java.en.Then;
import cucumber.api.java.ru.Если;
import eu.drus.jpa.unit.core.JpaUnitContext;
import eu.drus.jpa.unit.spi.DecoratorExecutor;
import eu.drus.jpa.unit.spi.TestInvocation;
// THEN
verifyZeroInteractions(executor);
}
@Test
public void testGetInstanceForSameTypeAlwaysReturnsSameObject() {
// GIVEN
// WHEN
final ClassA obj1 = factory.getInstance(ClassA.class);
final ClassA obj2 = factory.getInstance(ClassA.class);
// THEN
assertNotNull(obj1);
assertNotNull(obj2);
assertThat(obj1, equalTo(obj2));
}
@Test
public void testGetInstanceForSameTypeLeadsToExecutionOfProcessBeforeAllOnlyOnce() throws Exception {
// GIVEN
// WHEN
final ClassA obj1 = factory.getInstance(ClassA.class);
final ClassA obj2 = factory.getInstance(ClassA.class);
// THEN
assertNotNull(obj1);
assertNotNull(obj2);
| final ArgumentCaptor<TestInvocation> invocationCaptor = ArgumentCaptor.forClass(TestInvocation.class); |
dadrus/jpa-unit | neo4j/src/test/java/eu/drus/jpa/unit/neo4j/dataset/GraphComparatorTest.java | // Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/test/entities/B.java
// @Entity
// public class B {
//
// @Id
// private Long id;
// }
| import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.whenNew;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.jgrapht.Graph;
import org.jgrapht.graph.ClassBasedEdgeFactory;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.google.common.collect.ImmutableMap;
import eu.drus.jpa.unit.neo4j.test.entities.A;
import eu.drus.jpa.unit.neo4j.test.entities.B;
import eu.drus.jpa.unit.spi.AssertionErrorCollector; | package eu.drus.jpa.unit.neo4j.dataset;
@RunWith(PowerMockRunner.class)
@PrepareForTest(GraphComparator.class)
public class GraphComparatorTest {
private GraphElementFactory graphElementFactory;
@Mock
private DatabaseReader dbReader;
@Mock
private Connection connection;
@Mock
private AssertionErrorCollector errorCollector;
private Graph<Node, Edge> createGraph(final List<Node> nodes, final List<Edge> edges) {
final Graph<Node, Edge> graph = new DefaultDirectedGraph<>(new ClassBasedEdgeFactory<>(Edge.class));
nodes.forEach(graph::addVertex);
edges.forEach(e -> graph.addEdge(e.getSourceNode(), e.getTargetNode(), e));
return graph;
}
@Before
public void prepareTest() throws Exception {
whenNew(DatabaseReader.class).withAnyArguments().thenReturn(dbReader);
| // Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/test/entities/B.java
// @Entity
// public class B {
//
// @Id
// private Long id;
// }
// Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/dataset/GraphComparatorTest.java
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.whenNew;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.jgrapht.Graph;
import org.jgrapht.graph.ClassBasedEdgeFactory;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.google.common.collect.ImmutableMap;
import eu.drus.jpa.unit.neo4j.test.entities.A;
import eu.drus.jpa.unit.neo4j.test.entities.B;
import eu.drus.jpa.unit.spi.AssertionErrorCollector;
package eu.drus.jpa.unit.neo4j.dataset;
@RunWith(PowerMockRunner.class)
@PrepareForTest(GraphComparator.class)
public class GraphComparatorTest {
private GraphElementFactory graphElementFactory;
@Mock
private DatabaseReader dbReader;
@Mock
private Connection connection;
@Mock
private AssertionErrorCollector errorCollector;
private Graph<Node, Edge> createGraph(final List<Node> nodes, final List<Edge> edges) {
final Graph<Node, Edge> graph = new DefaultDirectedGraph<>(new ClassBasedEdgeFactory<>(Edge.class));
nodes.forEach(graph::addVertex);
edges.forEach(e -> graph.addEdge(e.getSourceNode(), e.getTargetNode(), e));
return graph;
}
@Before
public void prepareTest() throws Exception {
whenNew(DatabaseReader.class).withAnyArguments().thenReturn(dbReader);
| graphElementFactory = new GraphElementFactory(Arrays.asList(A.class, B.class)); |
dadrus/jpa-unit | neo4j/src/test/java/eu/drus/jpa/unit/neo4j/operation/DeleteAllOperationTest.java | // Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/test/entities/B.java
// @Entity
// public class B {
//
// @Id
// private Long id;
// }
| import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collections;
import org.jgrapht.Graph;
import org.jgrapht.graph.ClassBasedEdgeFactory;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
import com.google.common.collect.ImmutableMap;
import eu.drus.jpa.unit.neo4j.dataset.Edge;
import eu.drus.jpa.unit.neo4j.dataset.GraphElementFactory;
import eu.drus.jpa.unit.neo4j.dataset.Node;
import eu.drus.jpa.unit.neo4j.test.entities.A;
import eu.drus.jpa.unit.neo4j.test.entities.B; | package eu.drus.jpa.unit.neo4j.operation;
@RunWith(MockitoJUnitRunner.class)
public class DeleteAllOperationTest {
private GraphElementFactory graphElementFactory;
@Mock
private Connection connection;
@Spy
private DeleteAllOperation operation;
@Before
public void prepareMocks() throws SQLException {
doAnswer(i -> null).when(operation).executeQuery(any(Connection.class), anyString());
| // Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/test/entities/B.java
// @Entity
// public class B {
//
// @Id
// private Long id;
// }
// Path: neo4j/src/test/java/eu/drus/jpa/unit/neo4j/operation/DeleteAllOperationTest.java
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collections;
import org.jgrapht.Graph;
import org.jgrapht.graph.ClassBasedEdgeFactory;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
import com.google.common.collect.ImmutableMap;
import eu.drus.jpa.unit.neo4j.dataset.Edge;
import eu.drus.jpa.unit.neo4j.dataset.GraphElementFactory;
import eu.drus.jpa.unit.neo4j.dataset.Node;
import eu.drus.jpa.unit.neo4j.test.entities.A;
import eu.drus.jpa.unit.neo4j.test.entities.B;
package eu.drus.jpa.unit.neo4j.operation;
@RunWith(MockitoJUnitRunner.class)
public class DeleteAllOperationTest {
private GraphElementFactory graphElementFactory;
@Mock
private Connection connection;
@Spy
private DeleteAllOperation operation;
@Before
public void prepareMocks() throws SQLException {
doAnswer(i -> null).when(operation).executeQuery(any(Connection.class), anyString());
| graphElementFactory = new GraphElementFactory(Arrays.asList(A.class, B.class)); |
dadrus/jpa-unit | integration-test/base/src/main/java/eu/drus/jpa/unit/test/AbstractCdiEnabledNewDepositorFixture.java | // Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/Depositor.java
// @Entity
// @Table(name = "DEPOSITOR")
// public class Depositor {
//
// // persistence specific attributes
//
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private Long id;
//
// @Version
// @Column(name = "VERSION")
// private Long version;
//
// // entity attributes
//
// @Column(name = "NAME")
// @Basic(optional = false)
// private String name;
//
// @Column(name = "SURNAME")
// @Basic(optional = false)
// private String surname;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<Address> addresses = new HashSet<>();
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<ContactDetail> contactDetails = new HashSet<>();
//
// @OneToMany(mappedBy = "depositor", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Account> accounts = new HashSet<>();
//
// protected Depositor() {
// // for JPA
// }
//
// public Depositor(final String name, final String surname) {
// this.name = name;
// this.surname = surname;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public String getSurname() {
// return surname;
// }
//
// public void setSurname(final String surname) {
// this.surname = surname;
// }
//
// public Set<Account> getAccounts() {
// return Collections.unmodifiableSet(accounts);
// }
//
// protected boolean addAccount(final Account account) {
// return accounts.add(account);
// }
//
// public boolean removeAccount(final Account account) {
// if (accounts.remove(account)) {
// account.setDepositor(null);
// return true;
// }
// return false;
// }
//
// public boolean addAddress(final Address address) {
// return addresses.add(address);
// }
//
// public boolean removeAddress(final Address address) {
// return addresses.remove(address);
// }
//
// public Set<Address> getAddresses() {
// return Collections.unmodifiableSet(addresses);
// }
//
// public Set<ContactDetail> getContactDetails() {
// return Collections.unmodifiableSet(contactDetails);
// }
//
// public boolean addContactDetail(final ContactDetail contactDetail) {
// return contactDetails.add(contactDetail);
// }
//
// public boolean removeContactDetail(final ContactDetail contactDetail) {
// return contactDetails.remove(contactDetail);
// }
//
// @Override
// public String toString() {
// final ToStringBuilder builder = new ToStringBuilder(this);
// builder.append("id", id);
// builder.append("version", version);
// builder.append("name", name);
// builder.append("surname", surname);
// return builder.build();
// }
// }
//
// Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/InstantAccessAccount.java
// @Entity
// @DiscriminatorValue(value = "INSTANT_ACCESS_ACCOUNT")
// public class InstantAccessAccount extends Account {
//
// protected InstantAccessAccount() {
// super();
// // for JPA
// }
//
// public InstantAccessAccount(final Depositor depositor) {
// super(depositor);
// }
//
// @Override
// public float withdraw(final float amount) throws OperationNotSupportedException {
// throw new OperationNotSupportedException("Instant access account does not support money withdraw");
// }
//
// @Override
// public float transfer(final float amount, final Account toAccount) {
// final double balance = getBalance();
// final double balanceAfterTransfer = balance - amount;
// if (balanceAfterTransfer < 0.0f) {
// return 0;
// }
//
// final Date date = new Date(System.currentTimeMillis());
//
// addEntry(new AccountEntry(date, "ACC", "money transfer", amount, AccountEntryType.CREDIT));
// toAccount.addEntry(new AccountEntry(date, "ACC", "money transfer", amount, AccountEntryType.DEBIT));
// return amount;
// }
//
// @Override
// public float deposit(final float amount) throws OperationNotSupportedException {
// throw new OperationNotSupportedException("Instant access account does not support money deposit");
// }
//
// }
| import javax.inject.Inject;
import eu.drus.jpa.unit.api.Cleanup;
import eu.drus.jpa.unit.api.CleanupPhase;
import eu.drus.jpa.unit.api.ExpectedDataSets;
import eu.drus.jpa.unit.test.model.Depositor;
import eu.drus.jpa.unit.test.model.DepositorRepository;
import eu.drus.jpa.unit.test.model.InstantAccessAccount; | package eu.drus.jpa.unit.test;
public abstract class AbstractCdiEnabledNewDepositorFixture extends AbstractConcordionFixture {
@Inject
private DepositorRepository repository;
| // Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/Depositor.java
// @Entity
// @Table(name = "DEPOSITOR")
// public class Depositor {
//
// // persistence specific attributes
//
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private Long id;
//
// @Version
// @Column(name = "VERSION")
// private Long version;
//
// // entity attributes
//
// @Column(name = "NAME")
// @Basic(optional = false)
// private String name;
//
// @Column(name = "SURNAME")
// @Basic(optional = false)
// private String surname;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<Address> addresses = new HashSet<>();
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<ContactDetail> contactDetails = new HashSet<>();
//
// @OneToMany(mappedBy = "depositor", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Account> accounts = new HashSet<>();
//
// protected Depositor() {
// // for JPA
// }
//
// public Depositor(final String name, final String surname) {
// this.name = name;
// this.surname = surname;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public String getSurname() {
// return surname;
// }
//
// public void setSurname(final String surname) {
// this.surname = surname;
// }
//
// public Set<Account> getAccounts() {
// return Collections.unmodifiableSet(accounts);
// }
//
// protected boolean addAccount(final Account account) {
// return accounts.add(account);
// }
//
// public boolean removeAccount(final Account account) {
// if (accounts.remove(account)) {
// account.setDepositor(null);
// return true;
// }
// return false;
// }
//
// public boolean addAddress(final Address address) {
// return addresses.add(address);
// }
//
// public boolean removeAddress(final Address address) {
// return addresses.remove(address);
// }
//
// public Set<Address> getAddresses() {
// return Collections.unmodifiableSet(addresses);
// }
//
// public Set<ContactDetail> getContactDetails() {
// return Collections.unmodifiableSet(contactDetails);
// }
//
// public boolean addContactDetail(final ContactDetail contactDetail) {
// return contactDetails.add(contactDetail);
// }
//
// public boolean removeContactDetail(final ContactDetail contactDetail) {
// return contactDetails.remove(contactDetail);
// }
//
// @Override
// public String toString() {
// final ToStringBuilder builder = new ToStringBuilder(this);
// builder.append("id", id);
// builder.append("version", version);
// builder.append("name", name);
// builder.append("surname", surname);
// return builder.build();
// }
// }
//
// Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/InstantAccessAccount.java
// @Entity
// @DiscriminatorValue(value = "INSTANT_ACCESS_ACCOUNT")
// public class InstantAccessAccount extends Account {
//
// protected InstantAccessAccount() {
// super();
// // for JPA
// }
//
// public InstantAccessAccount(final Depositor depositor) {
// super(depositor);
// }
//
// @Override
// public float withdraw(final float amount) throws OperationNotSupportedException {
// throw new OperationNotSupportedException("Instant access account does not support money withdraw");
// }
//
// @Override
// public float transfer(final float amount, final Account toAccount) {
// final double balance = getBalance();
// final double balanceAfterTransfer = balance - amount;
// if (balanceAfterTransfer < 0.0f) {
// return 0;
// }
//
// final Date date = new Date(System.currentTimeMillis());
//
// addEntry(new AccountEntry(date, "ACC", "money transfer", amount, AccountEntryType.CREDIT));
// toAccount.addEntry(new AccountEntry(date, "ACC", "money transfer", amount, AccountEntryType.DEBIT));
// return amount;
// }
//
// @Override
// public float deposit(final float amount) throws OperationNotSupportedException {
// throw new OperationNotSupportedException("Instant access account does not support money deposit");
// }
//
// }
// Path: integration-test/base/src/main/java/eu/drus/jpa/unit/test/AbstractCdiEnabledNewDepositorFixture.java
import javax.inject.Inject;
import eu.drus.jpa.unit.api.Cleanup;
import eu.drus.jpa.unit.api.CleanupPhase;
import eu.drus.jpa.unit.api.ExpectedDataSets;
import eu.drus.jpa.unit.test.model.Depositor;
import eu.drus.jpa.unit.test.model.DepositorRepository;
import eu.drus.jpa.unit.test.model.InstantAccessAccount;
package eu.drus.jpa.unit.test;
public abstract class AbstractCdiEnabledNewDepositorFixture extends AbstractConcordionFixture {
@Inject
private DepositorRepository repository;
| public Depositor createNewCustomer(final String customerName) { |
dadrus/jpa-unit | integration-test/base/src/main/java/eu/drus/jpa/unit/test/AbstractCdiEnabledNewDepositorFixture.java | // Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/Depositor.java
// @Entity
// @Table(name = "DEPOSITOR")
// public class Depositor {
//
// // persistence specific attributes
//
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private Long id;
//
// @Version
// @Column(name = "VERSION")
// private Long version;
//
// // entity attributes
//
// @Column(name = "NAME")
// @Basic(optional = false)
// private String name;
//
// @Column(name = "SURNAME")
// @Basic(optional = false)
// private String surname;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<Address> addresses = new HashSet<>();
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<ContactDetail> contactDetails = new HashSet<>();
//
// @OneToMany(mappedBy = "depositor", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Account> accounts = new HashSet<>();
//
// protected Depositor() {
// // for JPA
// }
//
// public Depositor(final String name, final String surname) {
// this.name = name;
// this.surname = surname;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public String getSurname() {
// return surname;
// }
//
// public void setSurname(final String surname) {
// this.surname = surname;
// }
//
// public Set<Account> getAccounts() {
// return Collections.unmodifiableSet(accounts);
// }
//
// protected boolean addAccount(final Account account) {
// return accounts.add(account);
// }
//
// public boolean removeAccount(final Account account) {
// if (accounts.remove(account)) {
// account.setDepositor(null);
// return true;
// }
// return false;
// }
//
// public boolean addAddress(final Address address) {
// return addresses.add(address);
// }
//
// public boolean removeAddress(final Address address) {
// return addresses.remove(address);
// }
//
// public Set<Address> getAddresses() {
// return Collections.unmodifiableSet(addresses);
// }
//
// public Set<ContactDetail> getContactDetails() {
// return Collections.unmodifiableSet(contactDetails);
// }
//
// public boolean addContactDetail(final ContactDetail contactDetail) {
// return contactDetails.add(contactDetail);
// }
//
// public boolean removeContactDetail(final ContactDetail contactDetail) {
// return contactDetails.remove(contactDetail);
// }
//
// @Override
// public String toString() {
// final ToStringBuilder builder = new ToStringBuilder(this);
// builder.append("id", id);
// builder.append("version", version);
// builder.append("name", name);
// builder.append("surname", surname);
// return builder.build();
// }
// }
//
// Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/InstantAccessAccount.java
// @Entity
// @DiscriminatorValue(value = "INSTANT_ACCESS_ACCOUNT")
// public class InstantAccessAccount extends Account {
//
// protected InstantAccessAccount() {
// super();
// // for JPA
// }
//
// public InstantAccessAccount(final Depositor depositor) {
// super(depositor);
// }
//
// @Override
// public float withdraw(final float amount) throws OperationNotSupportedException {
// throw new OperationNotSupportedException("Instant access account does not support money withdraw");
// }
//
// @Override
// public float transfer(final float amount, final Account toAccount) {
// final double balance = getBalance();
// final double balanceAfterTransfer = balance - amount;
// if (balanceAfterTransfer < 0.0f) {
// return 0;
// }
//
// final Date date = new Date(System.currentTimeMillis());
//
// addEntry(new AccountEntry(date, "ACC", "money transfer", amount, AccountEntryType.CREDIT));
// toAccount.addEntry(new AccountEntry(date, "ACC", "money transfer", amount, AccountEntryType.DEBIT));
// return amount;
// }
//
// @Override
// public float deposit(final float amount) throws OperationNotSupportedException {
// throw new OperationNotSupportedException("Instant access account does not support money deposit");
// }
//
// }
| import javax.inject.Inject;
import eu.drus.jpa.unit.api.Cleanup;
import eu.drus.jpa.unit.api.CleanupPhase;
import eu.drus.jpa.unit.api.ExpectedDataSets;
import eu.drus.jpa.unit.test.model.Depositor;
import eu.drus.jpa.unit.test.model.DepositorRepository;
import eu.drus.jpa.unit.test.model.InstantAccessAccount; | package eu.drus.jpa.unit.test;
public abstract class AbstractCdiEnabledNewDepositorFixture extends AbstractConcordionFixture {
@Inject
private DepositorRepository repository;
public Depositor createNewCustomer(final String customerName) {
final String[] nameParts = customerName.split(" ");
final Depositor depositor = new Depositor(nameParts[0], nameParts[1]); | // Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/Depositor.java
// @Entity
// @Table(name = "DEPOSITOR")
// public class Depositor {
//
// // persistence specific attributes
//
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private Long id;
//
// @Version
// @Column(name = "VERSION")
// private Long version;
//
// // entity attributes
//
// @Column(name = "NAME")
// @Basic(optional = false)
// private String name;
//
// @Column(name = "SURNAME")
// @Basic(optional = false)
// private String surname;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<Address> addresses = new HashSet<>();
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// @JoinColumn(name = "DEPOSITOR_ID")
// private Set<ContactDetail> contactDetails = new HashSet<>();
//
// @OneToMany(mappedBy = "depositor", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Account> accounts = new HashSet<>();
//
// protected Depositor() {
// // for JPA
// }
//
// public Depositor(final String name, final String surname) {
// this.name = name;
// this.surname = surname;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public String getSurname() {
// return surname;
// }
//
// public void setSurname(final String surname) {
// this.surname = surname;
// }
//
// public Set<Account> getAccounts() {
// return Collections.unmodifiableSet(accounts);
// }
//
// protected boolean addAccount(final Account account) {
// return accounts.add(account);
// }
//
// public boolean removeAccount(final Account account) {
// if (accounts.remove(account)) {
// account.setDepositor(null);
// return true;
// }
// return false;
// }
//
// public boolean addAddress(final Address address) {
// return addresses.add(address);
// }
//
// public boolean removeAddress(final Address address) {
// return addresses.remove(address);
// }
//
// public Set<Address> getAddresses() {
// return Collections.unmodifiableSet(addresses);
// }
//
// public Set<ContactDetail> getContactDetails() {
// return Collections.unmodifiableSet(contactDetails);
// }
//
// public boolean addContactDetail(final ContactDetail contactDetail) {
// return contactDetails.add(contactDetail);
// }
//
// public boolean removeContactDetail(final ContactDetail contactDetail) {
// return contactDetails.remove(contactDetail);
// }
//
// @Override
// public String toString() {
// final ToStringBuilder builder = new ToStringBuilder(this);
// builder.append("id", id);
// builder.append("version", version);
// builder.append("name", name);
// builder.append("surname", surname);
// return builder.build();
// }
// }
//
// Path: integration-test/test-model/src/main/java/eu/drus/jpa/unit/test/model/InstantAccessAccount.java
// @Entity
// @DiscriminatorValue(value = "INSTANT_ACCESS_ACCOUNT")
// public class InstantAccessAccount extends Account {
//
// protected InstantAccessAccount() {
// super();
// // for JPA
// }
//
// public InstantAccessAccount(final Depositor depositor) {
// super(depositor);
// }
//
// @Override
// public float withdraw(final float amount) throws OperationNotSupportedException {
// throw new OperationNotSupportedException("Instant access account does not support money withdraw");
// }
//
// @Override
// public float transfer(final float amount, final Account toAccount) {
// final double balance = getBalance();
// final double balanceAfterTransfer = balance - amount;
// if (balanceAfterTransfer < 0.0f) {
// return 0;
// }
//
// final Date date = new Date(System.currentTimeMillis());
//
// addEntry(new AccountEntry(date, "ACC", "money transfer", amount, AccountEntryType.CREDIT));
// toAccount.addEntry(new AccountEntry(date, "ACC", "money transfer", amount, AccountEntryType.DEBIT));
// return amount;
// }
//
// @Override
// public float deposit(final float amount) throws OperationNotSupportedException {
// throw new OperationNotSupportedException("Instant access account does not support money deposit");
// }
//
// }
// Path: integration-test/base/src/main/java/eu/drus/jpa/unit/test/AbstractCdiEnabledNewDepositorFixture.java
import javax.inject.Inject;
import eu.drus.jpa.unit.api.Cleanup;
import eu.drus.jpa.unit.api.CleanupPhase;
import eu.drus.jpa.unit.api.ExpectedDataSets;
import eu.drus.jpa.unit.test.model.Depositor;
import eu.drus.jpa.unit.test.model.DepositorRepository;
import eu.drus.jpa.unit.test.model.InstantAccessAccount;
package eu.drus.jpa.unit.test;
public abstract class AbstractCdiEnabledNewDepositorFixture extends AbstractConcordionFixture {
@Inject
private DepositorRepository repository;
public Depositor createNewCustomer(final String customerName) {
final String[] nameParts = customerName.split(" ");
final Depositor depositor = new Depositor(nameParts[0], nameParts[1]); | new InstantAccessAccount(depositor); |
dadrus/jpa-unit | core/src/main/java/eu/drus/jpa/unit/core/DecoratorRegistrar.java | // Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
import eu.drus.jpa.unit.spi.TestClassDecorator;
import eu.drus.jpa.unit.spi.TestMethodDecorator; | package eu.drus.jpa.unit.core;
public class DecoratorRegistrar {
private static final ServiceLoader<TestClassDecorator> CLASS_DECORATORS = ServiceLoader.load(TestClassDecorator.class); | // Path: core/src/main/java/eu/drus/jpa/unit/spi/TestMethodDecorator.java
// public interface TestMethodDecorator extends TestDecorator {
//
// boolean isConfigurationSupported(ExecutionContext ctx);
//
// void beforeTest(TestInvocation invocation) throws Exception;
//
// void afterTest(TestInvocation invocation) throws Exception;
// }
// Path: core/src/main/java/eu/drus/jpa/unit/core/DecoratorRegistrar.java
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
import eu.drus.jpa.unit.spi.TestClassDecorator;
import eu.drus.jpa.unit.spi.TestMethodDecorator;
package eu.drus.jpa.unit.core;
public class DecoratorRegistrar {
private static final ServiceLoader<TestClassDecorator> CLASS_DECORATORS = ServiceLoader.load(TestClassDecorator.class); | private static final ServiceLoader<TestMethodDecorator> METHOD_DECORATORS = ServiceLoader.load(TestMethodDecorator.class); |
stanfy/goro | goro/src/test/java/com/stanfy/enroscar/goro/GoroImplTest.java | // Path: goro/src/main/java/com/stanfy/enroscar/goro/Goro.java
// static class GoroImpl extends Goro {
// /** Listeners handler. */
// final ListenersHandler listenersHandler = new ListenersHandler();
//
// /** Queues. */
// private final Queues queues;
//
// GoroImpl() {
// this(new Queues.Impl());
// }
//
// GoroImpl(final Queues queues) {
// this.queues = queues;
// }
//
// @Override
// public void addTaskListener(final GoroListener listener) {
// listenersHandler.addTaskListener(listener);
// }
//
// @Override
// public void removeTaskListener(final GoroListener listener) {
// listenersHandler.removeTaskListenerOrThrow(listener);
// }
//
// @Override
// public <T> ObservableFuture<T> schedule(final Callable<T> task) {
// return schedule(DEFAULT_QUEUE, task);
// }
//
// @Override
// public <T> ObservableFuture<T> schedule(final String queueName, final Callable<T> task) {
// if (task == null) {
// throw new IllegalArgumentException("Task must not be null");
// }
//
// GoroFuture<T> future = new GoroFuture<>(this, task);
// listenersHandler.postSchedule(task, queueName);
// queues.getExecutor(queueName).execute(future);
// return future;
// }
//
// @Override
// public Executor getExecutor(final String queueName) {
// return queues.getExecutor(queueName == null ? DEFAULT_QUEUE : queueName);
// }
//
// @Override
// protected void removeTasksInQueue(final String queueName) {
// queues.clear(queueName);
// }
// }
| import android.os.Build;
import com.stanfy.enroscar.goro.Goro.GoroImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.*; | package com.stanfy.enroscar.goro;
/**
* Tests for {@link com.stanfy.enroscar.goro.Goro.GoroImpl}.
*/
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class GoroImplTest {
/** Goro instance. */ | // Path: goro/src/main/java/com/stanfy/enroscar/goro/Goro.java
// static class GoroImpl extends Goro {
// /** Listeners handler. */
// final ListenersHandler listenersHandler = new ListenersHandler();
//
// /** Queues. */
// private final Queues queues;
//
// GoroImpl() {
// this(new Queues.Impl());
// }
//
// GoroImpl(final Queues queues) {
// this.queues = queues;
// }
//
// @Override
// public void addTaskListener(final GoroListener listener) {
// listenersHandler.addTaskListener(listener);
// }
//
// @Override
// public void removeTaskListener(final GoroListener listener) {
// listenersHandler.removeTaskListenerOrThrow(listener);
// }
//
// @Override
// public <T> ObservableFuture<T> schedule(final Callable<T> task) {
// return schedule(DEFAULT_QUEUE, task);
// }
//
// @Override
// public <T> ObservableFuture<T> schedule(final String queueName, final Callable<T> task) {
// if (task == null) {
// throw new IllegalArgumentException("Task must not be null");
// }
//
// GoroFuture<T> future = new GoroFuture<>(this, task);
// listenersHandler.postSchedule(task, queueName);
// queues.getExecutor(queueName).execute(future);
// return future;
// }
//
// @Override
// public Executor getExecutor(final String queueName) {
// return queues.getExecutor(queueName == null ? DEFAULT_QUEUE : queueName);
// }
//
// @Override
// protected void removeTasksInQueue(final String queueName) {
// queues.clear(queueName);
// }
// }
// Path: goro/src/test/java/com/stanfy/enroscar/goro/GoroImplTest.java
import android.os.Build;
import com.stanfy.enroscar.goro.Goro.GoroImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.*;
package com.stanfy.enroscar.goro;
/**
* Tests for {@link com.stanfy.enroscar.goro.Goro.GoroImpl}.
*/
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class GoroImplTest {
/** Goro instance. */ | private GoroImpl goro; |
stanfy/goro | goro/src/main/java/com/stanfy/enroscar/goro/Goro.java | // Path: goro/src/main/java/com/stanfy/enroscar/goro/BoundGoro.java
// static class BoundGoroImpl extends BoundGoro implements ServiceConnection {
//
// /** Instance of the context used to bind to GoroService. */
// private final Context context;
//
// /** Disconnection handler. */
// private final OnUnexpectedDisconnection disconnectionHandler;
//
// // Modified in the main thread only.
// private boolean unbindRequested;
//
// BoundGoroImpl(final Context context, final OnUnexpectedDisconnection disconnectionHandler) {
// this.context = context;
// this.disconnectionHandler = disconnectionHandler;
// }
//
// @Override
// public void bind() {
// unbindRequested = false;
// GoroService.bind(context, this);
// }
//
// @Override
// public void unbind() {
// if (updateDelegate(null)) {
// GoroService.unbind(context, this);
// unbindRequested = false;
// } else {
// unbindRequested = true;
// }
// }
//
// @Override
// public void onServiceConnected(final ComponentName name, final IBinder binder) {
// updateDelegate(Goro.from(binder));
// if (unbindRequested) {
// // If unbind is requested before we get a real connection, unbind here, after delegating all buffered calls.
// unbind();
// }
// }
//
// @Override
// public void onServiceDisconnected(final ComponentName name) {
// if (updateDelegate(null)) {
// /*
// It's the case when service was stopped by a system server.
// It can happen when user presses a stop button in application settings (in running apps section).
// Sometimes this happens on application update.
// */
// if (disconnectionHandler == null) {
// bind();
// } else {
// disconnectionHandler.onServiceDisconnected(this);
// }
// }
// }
//
// }
| import android.content.Context;
import android.os.IBinder;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import static com.stanfy.enroscar.goro.BoundGoro.BoundGoroImpl; | package com.stanfy.enroscar.goro;
/**
* Handles tasks in multiple queues.
*/
public abstract class Goro {
/** Default queue name. */
public static final String DEFAULT_QUEUE = "default";
/**
* Gives access to Goro instance that is provided by a service.
* @param binder Goro service binder
* @return Goro instance provided by the service
*/
public static Goro from(final IBinder binder) {
if (binder instanceof GoroService.GoroBinder) {
return ((GoroService.GoroBinder) binder).goro();
}
throw new IllegalArgumentException("Cannot get Goro from " + binder);
}
/**
* Creates a new Goro instance which uses {@link android.os.AsyncTask#THREAD_POOL_EXECUTOR}
* to delegate tasks on Post-Honeycomb devices or create a separate thread pool on earlier
* Android versions.
* @return instance of Goro
*/
public static Goro create() {
return new GoroImpl();
}
/**
* Creates a new Goro instance which uses the specified executor to delegate tasks.
* @param delegateExecutor executor Goro delegates tasks to
* @return instance of Goro
*/
public static Goro createWithDelegate(final Executor delegateExecutor) {
GoroImpl goro = new GoroImpl();
goro.queues.setDelegateExecutor(delegateExecutor);
return goro;
}
/**
* Creates a Goro implementation that binds to {@link com.stanfy.enroscar.goro.GoroService}
* in order to run scheduled tasks in service context.
* <p>
* This method is functionally identical to
* </p>
* <pre>
* BoundGoro goro = Goro.bindWith(context, new BoundGoro.OnUnexpectedDisconnection() {
* public void onServiceDisconnected(BoundGoro goro) {
* goro.bind();
* }
* });
* </pre>
* @param context context that will bind to the service
* @return Goro implementation that binds to {@link GoroService}.
* @see #bindWith(Context, BoundGoro.OnUnexpectedDisconnection)
*/
public static BoundGoro bindAndAutoReconnectWith(final Context context) {
if (context == null) {
throw new IllegalArgumentException("Context cannot be null");
} | // Path: goro/src/main/java/com/stanfy/enroscar/goro/BoundGoro.java
// static class BoundGoroImpl extends BoundGoro implements ServiceConnection {
//
// /** Instance of the context used to bind to GoroService. */
// private final Context context;
//
// /** Disconnection handler. */
// private final OnUnexpectedDisconnection disconnectionHandler;
//
// // Modified in the main thread only.
// private boolean unbindRequested;
//
// BoundGoroImpl(final Context context, final OnUnexpectedDisconnection disconnectionHandler) {
// this.context = context;
// this.disconnectionHandler = disconnectionHandler;
// }
//
// @Override
// public void bind() {
// unbindRequested = false;
// GoroService.bind(context, this);
// }
//
// @Override
// public void unbind() {
// if (updateDelegate(null)) {
// GoroService.unbind(context, this);
// unbindRequested = false;
// } else {
// unbindRequested = true;
// }
// }
//
// @Override
// public void onServiceConnected(final ComponentName name, final IBinder binder) {
// updateDelegate(Goro.from(binder));
// if (unbindRequested) {
// // If unbind is requested before we get a real connection, unbind here, after delegating all buffered calls.
// unbind();
// }
// }
//
// @Override
// public void onServiceDisconnected(final ComponentName name) {
// if (updateDelegate(null)) {
// /*
// It's the case when service was stopped by a system server.
// It can happen when user presses a stop button in application settings (in running apps section).
// Sometimes this happens on application update.
// */
// if (disconnectionHandler == null) {
// bind();
// } else {
// disconnectionHandler.onServiceDisconnected(this);
// }
// }
// }
//
// }
// Path: goro/src/main/java/com/stanfy/enroscar/goro/Goro.java
import android.content.Context;
import android.os.IBinder;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import static com.stanfy.enroscar.goro.BoundGoro.BoundGoroImpl;
package com.stanfy.enroscar.goro;
/**
* Handles tasks in multiple queues.
*/
public abstract class Goro {
/** Default queue name. */
public static final String DEFAULT_QUEUE = "default";
/**
* Gives access to Goro instance that is provided by a service.
* @param binder Goro service binder
* @return Goro instance provided by the service
*/
public static Goro from(final IBinder binder) {
if (binder instanceof GoroService.GoroBinder) {
return ((GoroService.GoroBinder) binder).goro();
}
throw new IllegalArgumentException("Cannot get Goro from " + binder);
}
/**
* Creates a new Goro instance which uses {@link android.os.AsyncTask#THREAD_POOL_EXECUTOR}
* to delegate tasks on Post-Honeycomb devices or create a separate thread pool on earlier
* Android versions.
* @return instance of Goro
*/
public static Goro create() {
return new GoroImpl();
}
/**
* Creates a new Goro instance which uses the specified executor to delegate tasks.
* @param delegateExecutor executor Goro delegates tasks to
* @return instance of Goro
*/
public static Goro createWithDelegate(final Executor delegateExecutor) {
GoroImpl goro = new GoroImpl();
goro.queues.setDelegateExecutor(delegateExecutor);
return goro;
}
/**
* Creates a Goro implementation that binds to {@link com.stanfy.enroscar.goro.GoroService}
* in order to run scheduled tasks in service context.
* <p>
* This method is functionally identical to
* </p>
* <pre>
* BoundGoro goro = Goro.bindWith(context, new BoundGoro.OnUnexpectedDisconnection() {
* public void onServiceDisconnected(BoundGoro goro) {
* goro.bind();
* }
* });
* </pre>
* @param context context that will bind to the service
* @return Goro implementation that binds to {@link GoroService}.
* @see #bindWith(Context, BoundGoro.OnUnexpectedDisconnection)
*/
public static BoundGoro bindAndAutoReconnectWith(final Context context) {
if (context == null) {
throw new IllegalArgumentException("Context cannot be null");
} | return new BoundGoroImpl(context, null); |
stanfy/goro | goro/src/test/java/com/stanfy/enroscar/goro/support/RxGoroTest.java | // Path: goro/src/test/java/com/stanfy/enroscar/goro/TestingQueues.java
// public class TestingQueues implements Queues {
//
// /** Scheduled tasks. */
// private final ArrayList<Runnable> tasks = new ArrayList<>();
//
// /** Delegate executor. */
// private Executor delegateExecutor = new Executor() {
// @Override
// public void execute(@SuppressWarnings("NullableProblems") final Runnable command) {
// tasks.add(command);
// }
// };
//
// /** Last queue name. */
// private String lastQueueName;
//
// @Override
// public void setDelegateExecutor(final Executor delegate) {
// delegateExecutor = delegate;
// }
//
// @Override
// public Executor getExecutor(final String queueName) {
// lastQueueName = queueName;
// return new TaskQueueExecutor(delegateExecutor);
// }
//
// @Override
// public void clear(final String queueName) {
// lastQueueName = queueName;
// tasks.clear();
// }
//
// public String getLastQueueName() {
// return lastQueueName;
// }
//
// public void executeAll() {
// for (Runnable command : tasks) {
// command.run();
// }
// tasks.clear();
// }
//
// }
//
// Path: goro/src/test/java/com/stanfy/enroscar/goro/GoroImplTest.java
// public static GoroImpl createGoroWith(TestingQueues queues) {
// return new GoroImpl(queues);
// }
| import com.stanfy.enroscar.goro.BuildConfig;
import com.stanfy.enroscar.goro.TestingQueues;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import rx.Observable;
import rx.Scheduler;
import rx.Subscription;
import rx.observers.TestSubscriber;
import static com.stanfy.enroscar.goro.GoroImplTest.createGoroWith; | package com.stanfy.enroscar.goro.support;
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 19)
public class RxGoroTest {
private RxGoro rxGoro; | // Path: goro/src/test/java/com/stanfy/enroscar/goro/TestingQueues.java
// public class TestingQueues implements Queues {
//
// /** Scheduled tasks. */
// private final ArrayList<Runnable> tasks = new ArrayList<>();
//
// /** Delegate executor. */
// private Executor delegateExecutor = new Executor() {
// @Override
// public void execute(@SuppressWarnings("NullableProblems") final Runnable command) {
// tasks.add(command);
// }
// };
//
// /** Last queue name. */
// private String lastQueueName;
//
// @Override
// public void setDelegateExecutor(final Executor delegate) {
// delegateExecutor = delegate;
// }
//
// @Override
// public Executor getExecutor(final String queueName) {
// lastQueueName = queueName;
// return new TaskQueueExecutor(delegateExecutor);
// }
//
// @Override
// public void clear(final String queueName) {
// lastQueueName = queueName;
// tasks.clear();
// }
//
// public String getLastQueueName() {
// return lastQueueName;
// }
//
// public void executeAll() {
// for (Runnable command : tasks) {
// command.run();
// }
// tasks.clear();
// }
//
// }
//
// Path: goro/src/test/java/com/stanfy/enroscar/goro/GoroImplTest.java
// public static GoroImpl createGoroWith(TestingQueues queues) {
// return new GoroImpl(queues);
// }
// Path: goro/src/test/java/com/stanfy/enroscar/goro/support/RxGoroTest.java
import com.stanfy.enroscar.goro.BuildConfig;
import com.stanfy.enroscar.goro.TestingQueues;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import rx.Observable;
import rx.Scheduler;
import rx.Subscription;
import rx.observers.TestSubscriber;
import static com.stanfy.enroscar.goro.GoroImplTest.createGoroWith;
package com.stanfy.enroscar.goro.support;
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 19)
public class RxGoroTest {
private RxGoro rxGoro; | private TestingQueues queues = new TestingQueues(); |
stanfy/goro | goro/src/test/java/com/stanfy/enroscar/goro/support/RxGoroTest.java | // Path: goro/src/test/java/com/stanfy/enroscar/goro/TestingQueues.java
// public class TestingQueues implements Queues {
//
// /** Scheduled tasks. */
// private final ArrayList<Runnable> tasks = new ArrayList<>();
//
// /** Delegate executor. */
// private Executor delegateExecutor = new Executor() {
// @Override
// public void execute(@SuppressWarnings("NullableProblems") final Runnable command) {
// tasks.add(command);
// }
// };
//
// /** Last queue name. */
// private String lastQueueName;
//
// @Override
// public void setDelegateExecutor(final Executor delegate) {
// delegateExecutor = delegate;
// }
//
// @Override
// public Executor getExecutor(final String queueName) {
// lastQueueName = queueName;
// return new TaskQueueExecutor(delegateExecutor);
// }
//
// @Override
// public void clear(final String queueName) {
// lastQueueName = queueName;
// tasks.clear();
// }
//
// public String getLastQueueName() {
// return lastQueueName;
// }
//
// public void executeAll() {
// for (Runnable command : tasks) {
// command.run();
// }
// tasks.clear();
// }
//
// }
//
// Path: goro/src/test/java/com/stanfy/enroscar/goro/GoroImplTest.java
// public static GoroImpl createGoroWith(TestingQueues queues) {
// return new GoroImpl(queues);
// }
| import com.stanfy.enroscar.goro.BuildConfig;
import com.stanfy.enroscar.goro.TestingQueues;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import rx.Observable;
import rx.Scheduler;
import rx.Subscription;
import rx.observers.TestSubscriber;
import static com.stanfy.enroscar.goro.GoroImplTest.createGoroWith; | package com.stanfy.enroscar.goro.support;
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 19)
public class RxGoroTest {
private RxGoro rxGoro;
private TestingQueues queues = new TestingQueues();
@Before
public void init() { | // Path: goro/src/test/java/com/stanfy/enroscar/goro/TestingQueues.java
// public class TestingQueues implements Queues {
//
// /** Scheduled tasks. */
// private final ArrayList<Runnable> tasks = new ArrayList<>();
//
// /** Delegate executor. */
// private Executor delegateExecutor = new Executor() {
// @Override
// public void execute(@SuppressWarnings("NullableProblems") final Runnable command) {
// tasks.add(command);
// }
// };
//
// /** Last queue name. */
// private String lastQueueName;
//
// @Override
// public void setDelegateExecutor(final Executor delegate) {
// delegateExecutor = delegate;
// }
//
// @Override
// public Executor getExecutor(final String queueName) {
// lastQueueName = queueName;
// return new TaskQueueExecutor(delegateExecutor);
// }
//
// @Override
// public void clear(final String queueName) {
// lastQueueName = queueName;
// tasks.clear();
// }
//
// public String getLastQueueName() {
// return lastQueueName;
// }
//
// public void executeAll() {
// for (Runnable command : tasks) {
// command.run();
// }
// tasks.clear();
// }
//
// }
//
// Path: goro/src/test/java/com/stanfy/enroscar/goro/GoroImplTest.java
// public static GoroImpl createGoroWith(TestingQueues queues) {
// return new GoroImpl(queues);
// }
// Path: goro/src/test/java/com/stanfy/enroscar/goro/support/RxGoroTest.java
import com.stanfy.enroscar.goro.BuildConfig;
import com.stanfy.enroscar.goro.TestingQueues;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import rx.Observable;
import rx.Scheduler;
import rx.Subscription;
import rx.observers.TestSubscriber;
import static com.stanfy.enroscar.goro.GoroImplTest.createGoroWith;
package com.stanfy.enroscar.goro.support;
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 19)
public class RxGoroTest {
private RxGoro rxGoro;
private TestingQueues queues = new TestingQueues();
@Before
public void init() { | rxGoro = new RxGoro(createGoroWith(queues)); |
itoshkov/nand2tetris-emu | BuiltInVMCode/src/main/java/builtInVMCode/Jack_Keyboard.java | // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
| import Hack.VMEmulator.TerminateVMProgramThrowable; | /********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Keyboard class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Keyboard extends JackOSClass {
public static void init() {
}
| // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
// Path: BuiltInVMCode/src/main/java/builtInVMCode/Jack_Keyboard.java
import Hack.VMEmulator.TerminateVMProgramThrowable;
/********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Keyboard class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Keyboard extends JackOSClass {
public static void init() {
}
| public static char keyPressed() throws TerminateVMProgramThrowable { |
itoshkov/nand2tetris-emu | BuiltInVMCode/src/main/java/builtInVMCode/Jack_Screen.java | // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
| import Hack.VMEmulator.TerminateVMProgramThrowable; | /********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Screen class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Screen extends JackOSClass {
private static boolean black;
public static void init() {
black = true;
}
| // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
// Path: BuiltInVMCode/src/main/java/builtInVMCode/Jack_Screen.java
import Hack.VMEmulator.TerminateVMProgramThrowable;
/********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Screen class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Screen extends JackOSClass {
private static boolean black;
public static void init() {
black = true;
}
| public static void clearScreen() throws TerminateVMProgramThrowable { |
itoshkov/nand2tetris-emu | BuiltInVMCode/src/main/java/builtInVMCode/Jack_Memory.java | // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
| import Hack.VMEmulator.TerminateVMProgramThrowable; | /********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Sys class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Memory extends JackOSClass {
public static void init() | // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
// Path: BuiltInVMCode/src/main/java/builtInVMCode/Jack_Memory.java
import Hack.VMEmulator.TerminateVMProgramThrowable;
/********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Sys class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Memory extends JackOSClass {
public static void init() | throws TerminateVMProgramThrowable { |
itoshkov/nand2tetris-emu | BuiltInVMCode/src/main/java/builtInVMCode/Jack_Array.java | // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
| import Hack.VMEmulator.TerminateVMProgramThrowable; | /********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Array class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Array extends JackOSClass {
| // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
// Path: BuiltInVMCode/src/main/java/builtInVMCode/Jack_Array.java
import Hack.VMEmulator.TerminateVMProgramThrowable;
/********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Array class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Array extends JackOSClass {
| public static short NEW(short size) throws TerminateVMProgramThrowable { |
itoshkov/nand2tetris-emu | BuiltInVMCode/src/main/java/builtInVMCode/Jack_String.java | // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
| import Hack.VMEmulator.TerminateVMProgramThrowable; | /********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the String class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_String extends JackOSClass {
| // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
// Path: BuiltInVMCode/src/main/java/builtInVMCode/Jack_String.java
import Hack.VMEmulator.TerminateVMProgramThrowable;
/********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the String class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_String extends JackOSClass {
| public static short NEW(short maxLength) throws TerminateVMProgramThrowable { |
itoshkov/nand2tetris-emu | BuiltInVMCode/src/main/java/builtInVMCode/Jack_Math.java | // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
| import Hack.VMEmulator.TerminateVMProgramThrowable; | /********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Math class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Math extends JackOSClass {
public static void init() {
}
public static short abs(short x) {
return (x < 0) ? (short) -x : x;
}
public static short multiply(short x, short y) {
return (short) (x * y);
}
| // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
// Path: BuiltInVMCode/src/main/java/builtInVMCode/Jack_Math.java
import Hack.VMEmulator.TerminateVMProgramThrowable;
/********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Math class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Math extends JackOSClass {
public static void init() {
}
public static short abs(short x) {
return (x < 0) ? (short) -x : x;
}
public static short multiply(short x, short y) {
return (short) (x * y);
}
| public static short divide(short x, short y) throws TerminateVMProgramThrowable { |
itoshkov/nand2tetris-emu | BuiltInVMCode/src/main/java/builtInVMCode/Jack_Output.java | // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
| import Hack.VMEmulator.TerminateVMProgramThrowable;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator; | create(116, 4, 6, 6, 15, 6, 6, 6, 54, 28, 0, 0);
create(117, 0, 0, 0, 27, 27, 27, 27, 27, 54, 0, 0);
create(118, 0, 0, 0, 51, 51, 51, 51, 30, 12, 0, 0);
create(119, 0, 0, 0, 51, 51, 51, 63, 63, 18, 0, 0);
create(120, 0, 0, 0, 51, 30, 12, 12, 30, 51, 0, 0);
create(121, 0, 0, 0, 51, 51, 51, 62, 48, 24, 15, 0);
create(122, 0, 0, 0, 63, 27, 12, 6, 51, 63, 0, 0);
create(123, 56, 12, 12, 12, 7, 12, 12, 12, 56, 0, 0);
create(124, 12, 12, 12, 12, 12, 12, 12, 12, 12, 0, 0);
create(125, 7, 12, 12, 12, 56, 12, 12, 12, 7, 0, 0);
create(126, 38, 45, 25, 0, 0, 0, 0, 0, 0, 0, 0);
}
private static void create(int c, int line0, int line1, int line2,
int line3, int line4, int line5,
int line6, int line7, int line8,
int line9, int line10) {
map[c][0] = line0;
map[c][1] = line1;
map[c][2] = line2;
map[c][3] = line3;
map[c][4] = line4;
map[c][5] = line5;
map[c][6] = line6;
map[c][7] = line7;
map[c][8] = line8;
map[c][9] = line9;
map[c][10] = line10;
}
| // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
// Path: BuiltInVMCode/src/main/java/builtInVMCode/Jack_Output.java
import Hack.VMEmulator.TerminateVMProgramThrowable;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
create(116, 4, 6, 6, 15, 6, 6, 6, 54, 28, 0, 0);
create(117, 0, 0, 0, 27, 27, 27, 27, 27, 54, 0, 0);
create(118, 0, 0, 0, 51, 51, 51, 51, 30, 12, 0, 0);
create(119, 0, 0, 0, 51, 51, 51, 63, 63, 18, 0, 0);
create(120, 0, 0, 0, 51, 30, 12, 12, 30, 51, 0, 0);
create(121, 0, 0, 0, 51, 51, 51, 62, 48, 24, 15, 0);
create(122, 0, 0, 0, 63, 27, 12, 6, 51, 63, 0, 0);
create(123, 56, 12, 12, 12, 7, 12, 12, 12, 56, 0, 0);
create(124, 12, 12, 12, 12, 12, 12, 12, 12, 12, 0, 0);
create(125, 7, 12, 12, 12, 56, 12, 12, 12, 7, 0, 0);
create(126, 38, 45, 25, 0, 0, 0, 0, 0, 0, 0, 0);
}
private static void create(int c, int line0, int line1, int line2,
int line3, int line4, int line5,
int line6, int line7, int line8,
int line9, int line10) {
map[c][0] = line0;
map[c][1] = line1;
map[c][2] = line2;
map[c][3] = line3;
map[c][4] = line4;
map[c][5] = line5;
map[c][6] = line6;
map[c][7] = line7;
map[c][8] = line8;
map[c][9] = line9;
map[c][10] = line10;
}
| private static void drawChar(int c) throws TerminateVMProgramThrowable { |
itoshkov/nand2tetris-emu | HackGUIPackage/src/main/java/HackGUI/ProfilerWindow.java | // Path: HackPackage/src/main/java/Hack/Controller/Profiler.java
// public interface Profiler {
//
// void reset();
//
// String[] getTabNames();
//
// String[] getTableHeaders(int tab);
//
// Map<String, AtomicInteger> getData(int tab);
//
// boolean isEnabled();
//
// void setEnabled(boolean enabled);
// }
| import Hack.Controller.Profiler;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import static java.util.Map.Entry; | package HackGUI;
public class ProfilerWindow extends JFrame {
public static final Comparator<Entry<String, AtomicInteger>> ENTRY_COMPARATOR =
new Comparator<Entry<String, AtomicInteger>>() {
@Override
public int compare(Entry<String, AtomicInteger> o1, Entry<String, AtomicInteger> o2) {
return o2.getValue().get() - o1.getValue().get();
}
}; | // Path: HackPackage/src/main/java/Hack/Controller/Profiler.java
// public interface Profiler {
//
// void reset();
//
// String[] getTabNames();
//
// String[] getTableHeaders(int tab);
//
// Map<String, AtomicInteger> getData(int tab);
//
// boolean isEnabled();
//
// void setEnabled(boolean enabled);
// }
// Path: HackGUIPackage/src/main/java/HackGUI/ProfilerWindow.java
import Hack.Controller.Profiler;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import static java.util.Map.Entry;
package HackGUI;
public class ProfilerWindow extends JFrame {
public static final Comparator<Entry<String, AtomicInteger>> ENTRY_COMPARATOR =
new Comparator<Entry<String, AtomicInteger>>() {
@Override
public int compare(Entry<String, AtomicInteger> o1, Entry<String, AtomicInteger> o2) {
return o2.getValue().get() - o1.getValue().get();
}
}; | private final Profiler profiler; |
itoshkov/nand2tetris-emu | BuiltInVMCode/src/main/java/builtInVMCode/Jack_Sys.java | // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
| import Hack.VMEmulator.TerminateVMProgramThrowable; | /********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Sys class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Sys extends JackOSClass {
| // Path: SimulatorsPackage/src/main/java/Hack/VMEmulator/TerminateVMProgramThrowable.java
// public class TerminateVMProgramThrowable extends Throwable
// {
// /**
// * Constructs a new TerminateVMProgramThrowable with the given message.
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable(String message) {
// super(message);
// }
//
// /**
// * Constructs a new TerminateVMProgramThrowable with no message
// * Don't allow builtins (which are outside this package) to construct.
// */
// TerminateVMProgramThrowable() {
// super();
// }
//
// }
// Path: BuiltInVMCode/src/main/java/builtInVMCode/Jack_Sys.java
import Hack.VMEmulator.TerminateVMProgramThrowable;
/********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package builtInVMCode;
/**
* A built-in implementation for the Sys class of the Jack OS.
*/
@SuppressWarnings("UnusedDeclaration")
public class Jack_Sys extends JackOSClass {
| public static void init() throws TerminateVMProgramThrowable { |
itoshkov/nand2tetris-emu | HackGUIPackage/src/main/java/HackGUI/BreakpointWindow.java | // Path: HackPackage/src/main/java/Hack/Controller/Breakpoint.java
// public class Breakpoint implements Comparable<Breakpoint> {
//
// // The variable name
// private final String varName;
//
// // The desired value
// private final String value;
//
// // The status of the breakpoint
// private boolean reached;
//
// /**
// * Constructs a new Breakpoint with the given variable name and desired value.
// */
// public Breakpoint(String varName, String value) {
// this.varName = varName;
// this.value = value;
// reached = false;
// }
//
// /**
// * Returns the variable name.
// */
// public String getVarName() {
// return varName;
// }
//
// /**
// * Returns the breakpoint value.
// */
// public String getValue() {
// return value;
// }
//
// /**
// * sets the breakpoint "off" - puts it into "not reached" state.
// */
// public void off() {
// reached = false;
// }
//
// /**
// * Sets the breakpoint "on" - puts it into "reached" state.
// */
// public void on() {
// reached = true;
// }
//
// /**
// * Returns true if the breakpoint is reached.
// */
// public boolean isReached() {
// return reached;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Breakpoint that = (Breakpoint) o;
//
// return varName.equals(that.varName) && value.equals(that.value);
// }
//
// @Override
// public int hashCode() {
// int result = varName.hashCode();
// result = 31 * result + value.hashCode();
// return result;
// }
//
// @Override
// public int compareTo(Breakpoint o) {
// final int c = varName.compareTo(o.varName);
// return c != 0? c : value.compareTo(o.value);
// }
// }
| import Hack.Controller.Breakpoint;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*; | /********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package HackGUI;
/**
* This class represents the gui of a breakpoint panel.
*/
public class BreakpointWindow extends JFrame implements MouseListener, BreakpointChangedListener {
// The table of breakpoints.
private JTable breakpointTable;
// The vector of breakpoints. | // Path: HackPackage/src/main/java/Hack/Controller/Breakpoint.java
// public class Breakpoint implements Comparable<Breakpoint> {
//
// // The variable name
// private final String varName;
//
// // The desired value
// private final String value;
//
// // The status of the breakpoint
// private boolean reached;
//
// /**
// * Constructs a new Breakpoint with the given variable name and desired value.
// */
// public Breakpoint(String varName, String value) {
// this.varName = varName;
// this.value = value;
// reached = false;
// }
//
// /**
// * Returns the variable name.
// */
// public String getVarName() {
// return varName;
// }
//
// /**
// * Returns the breakpoint value.
// */
// public String getValue() {
// return value;
// }
//
// /**
// * sets the breakpoint "off" - puts it into "not reached" state.
// */
// public void off() {
// reached = false;
// }
//
// /**
// * Sets the breakpoint "on" - puts it into "reached" state.
// */
// public void on() {
// reached = true;
// }
//
// /**
// * Returns true if the breakpoint is reached.
// */
// public boolean isReached() {
// return reached;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Breakpoint that = (Breakpoint) o;
//
// return varName.equals(that.varName) && value.equals(that.value);
// }
//
// @Override
// public int hashCode() {
// int result = varName.hashCode();
// result = 31 * result + value.hashCode();
// return result;
// }
//
// @Override
// public int compareTo(Breakpoint o) {
// final int c = varName.compareTo(o.varName);
// return c != 0? c : value.compareTo(o.value);
// }
// }
// Path: HackGUIPackage/src/main/java/HackGUI/BreakpointWindow.java
import Hack.Controller.Breakpoint;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
/********************************************************************************
* The contents of this file are subject to the GNU General Public License *
* (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* without warranty of any kind, either expressed or implied. See the License *
* for the specific language governing rights and limitations under the *
* License. *
* *
* This file was originally developed as part of the software suite that *
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
* MIT Press 2005. If you modify the contents of this file, please document and *
* mark your changes clearly, for the benefit of others. *
********************************************************************************/
package HackGUI;
/**
* This class represents the gui of a breakpoint panel.
*/
public class BreakpointWindow extends JFrame implements MouseListener, BreakpointChangedListener {
// The table of breakpoints.
private JTable breakpointTable;
// The vector of breakpoints. | private Vector<Breakpoint> breakpoints; |
Meisterschueler/ogn-viewer-android | app/src/test/java/com/meisterschueler/ognviewer/AprsFilterManagerTest.java | // Path: app/src/main/java/com/meisterschueler/ognviewer/common/AprsFilterManager.java
// public class AprsFilterManager {
// public static Circle parse(String aprs_filter) {
// String re_float = "[+-]?((\\d+\\.?\\d*)|(\\.\\d+))";
// String re_range = "^r/(" + re_float + ")/(" + re_float + ")/(" + re_float + ")$";
//
// Pattern pattern = Pattern.compile(re_range);
// Matcher matcher = pattern.matcher(aprs_filter);
//
// Circle result = null;
// if (matcher.matches()) {
// result = new Circle();
// result.lat = Double.parseDouble(matcher.group(1));
// result.lon = Double.parseDouble(matcher.group(5));
// result.radius = Double.parseDouble(matcher.group(9));
// }
//
// return result;
// }
//
// public static String latLngToAprsFilter(double lat, double lon, double radius) {
// return String.format(Locale.US, "r/%1$.3f/%2$.3f/%3$.1f", lat, lon, radius/1000.0);
// }
//
// public static String latLngToAprsFilter(double lat, double lon) {
// return latLngToAprsFilter(lat, lon, AppConstants.DEFAULT_APRS_FILTER_RADIUS);
// }
//
// public static class Circle {
// double lat;
// double lon;
// double radius;
//
//
// public double getLat() {
// return lat;
// }
//
// public double getLon() {
// return lon;
// }
//
// public double getRadius() {
// return radius;
// }
//
// }
//
// }
| import com.meisterschueler.ognviewer.common.AprsFilterManager;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull; | package com.meisterschueler.ognviewer;
public class AprsFilterManagerTest {
private static final double DELTA = 1e-15;
@Test
public void simpleIntegers() { | // Path: app/src/main/java/com/meisterschueler/ognviewer/common/AprsFilterManager.java
// public class AprsFilterManager {
// public static Circle parse(String aprs_filter) {
// String re_float = "[+-]?((\\d+\\.?\\d*)|(\\.\\d+))";
// String re_range = "^r/(" + re_float + ")/(" + re_float + ")/(" + re_float + ")$";
//
// Pattern pattern = Pattern.compile(re_range);
// Matcher matcher = pattern.matcher(aprs_filter);
//
// Circle result = null;
// if (matcher.matches()) {
// result = new Circle();
// result.lat = Double.parseDouble(matcher.group(1));
// result.lon = Double.parseDouble(matcher.group(5));
// result.radius = Double.parseDouble(matcher.group(9));
// }
//
// return result;
// }
//
// public static String latLngToAprsFilter(double lat, double lon, double radius) {
// return String.format(Locale.US, "r/%1$.3f/%2$.3f/%3$.1f", lat, lon, radius/1000.0);
// }
//
// public static String latLngToAprsFilter(double lat, double lon) {
// return latLngToAprsFilter(lat, lon, AppConstants.DEFAULT_APRS_FILTER_RADIUS);
// }
//
// public static class Circle {
// double lat;
// double lon;
// double radius;
//
//
// public double getLat() {
// return lat;
// }
//
// public double getLon() {
// return lon;
// }
//
// public double getRadius() {
// return radius;
// }
//
// }
//
// }
// Path: app/src/test/java/com/meisterschueler/ognviewer/AprsFilterManagerTest.java
import com.meisterschueler.ognviewer.common.AprsFilterManager;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
package com.meisterschueler.ognviewer;
public class AprsFilterManagerTest {
private static final double DELTA = 1e-15;
@Test
public void simpleIntegers() { | AprsFilterManager.Circle result = AprsFilterManager.parse("r/52/13/100"); |
Meisterschueler/ogn-viewer-android | app/src/test/java/com/meisterschueler/ognviewer/common/UtilsTest.java | // Path: app/src/main/java/com/meisterschueler/ognviewer/common/Utils.java
// public class Utils {
// private final static float METERS_TO_FEET = 3.2808398950131f;
// private final static float KMH_TO_MPH = 0.62137119223733f;
// private final static float KMH_TO_KT = 0.53995680346039f;
// private final static float MS_TO_FPM = 196.8504f;
//
// public static float getHue(float value, float min, float max, int minColor, int maxColor) {
// float hue;
// if (min == max || value <= min) {
// hue = minColor;
// } else if (value > max) {
// hue = maxColor;
// } else {
// float colorValue = (value - min) / (max - min); // from 0.0 to 1.0
// hue = minColor + colorValue * (maxColor - minColor);
// }
//
// float result = hue % 360.0f;
// if (result >= 360.0 || result < 0) {
// result = 0;
// }
//
// return result;
// }
//
// public static float metersToFeet(float meters) {
// return meters * METERS_TO_FEET;
// }
//
// public static float kmhToMph(float kmh) {
// return kmh * KMH_TO_MPH;
// }
//
// public static float kmhToKt(float kmh) {
// return kmh * KMH_TO_KT;
// }
//
// public static float msToFpm(float ms) {
// return ms * MS_TO_FPM;
// }
// }
| import com.meisterschueler.ognviewer.common.Utils;
import org.junit.Assert;
import org.junit.Test; | package com.meisterschueler.ognviewer.common;
public class UtilsTest {
@Test
public void getHue() { | // Path: app/src/main/java/com/meisterschueler/ognviewer/common/Utils.java
// public class Utils {
// private final static float METERS_TO_FEET = 3.2808398950131f;
// private final static float KMH_TO_MPH = 0.62137119223733f;
// private final static float KMH_TO_KT = 0.53995680346039f;
// private final static float MS_TO_FPM = 196.8504f;
//
// public static float getHue(float value, float min, float max, int minColor, int maxColor) {
// float hue;
// if (min == max || value <= min) {
// hue = minColor;
// } else if (value > max) {
// hue = maxColor;
// } else {
// float colorValue = (value - min) / (max - min); // from 0.0 to 1.0
// hue = minColor + colorValue * (maxColor - minColor);
// }
//
// float result = hue % 360.0f;
// if (result >= 360.0 || result < 0) {
// result = 0;
// }
//
// return result;
// }
//
// public static float metersToFeet(float meters) {
// return meters * METERS_TO_FEET;
// }
//
// public static float kmhToMph(float kmh) {
// return kmh * KMH_TO_MPH;
// }
//
// public static float kmhToKt(float kmh) {
// return kmh * KMH_TO_KT;
// }
//
// public static float msToFpm(float ms) {
// return ms * MS_TO_FPM;
// }
// }
// Path: app/src/test/java/com/meisterschueler/ognviewer/common/UtilsTest.java
import com.meisterschueler.ognviewer.common.Utils;
import org.junit.Assert;
import org.junit.Test;
package com.meisterschueler.ognviewer.common;
public class UtilsTest {
@Test
public void getHue() { | float hue = Utils.getHue(0, 0, 100, 120, 360); |
Meisterschueler/ogn-viewer-android | app/src/main/java/com/meisterschueler/ognviewer/activity/base/BaseActivity.java | // Path: app/src/main/java/com/meisterschueler/ognviewer/common/AppConstants.java
// public class AppConstants {
// // permission request codes (must be 0 to 65535 for AppCompat!)
// // so keep it unsigned short: https://stackoverflow.com/questions/33331073/android-what-to-choose-for-requestcode-values/33331459#33331459
// public static final int REQUEST_CODE_LOCATION_ZOOM = 54321;
// public static final int REQUEST_CODE_LOCATION_FILTER = 2468;
// public static final int REQUEST_CODE_LOCATION_TCP_UPDATES = 12341;
// public static final int REQUEST_CODE_LOCATION_TCP_UPDATES_FROM_SERVICE = 1234;
// public static final int REQUEST_CODE_STORAGE_IMPORT = 20201;
// public static final int REQUEST_CODE_STORAGE_EXPORT = 20202;
//
// // Intents
// public static final String INTENT_AIRCRAFT_BEACON = "AIRCRAFT-BEACON";
// public static final String INTENT_RECEIVER_BEACON = "RECEIVER-BEACON";
// public static final String INTENT_AIRCRAFT_ACTION = "AIRCRAFT_ACTION";
// public static final String INTENT_LOCATION = "LOCATION";
//
// /**
// * after this time inactive aircraft are removed
// */
// public static final int DEFAULT_AIRCRAFT_TIMEOUT_IN_SEC = 300;
//
// /**
// * zoom factor for "go to current location"
// */
// public static final int DEFAULT_MAP_ZOOM = 7;
//
// /**
// * request code for settings activity
// */
// public static final int ACTIVITY_REQUEST_CODE_SETTINGS = 2000;
//
// /**
// * TCP port for other apps to connect
// */
// public static final int TCP_SERVER_PORT = 4353;
//
// /**
// * REST API base url for flightpath
// */
// public static final String FLIGHTPATH_API_BASE_URL = "http://ogn.dominik-p.de:18820/api/";
//
// /**
// * restore markers after a little delay to prevent black screen issue
// */
// public static final int RESTORE_MAP_AFTER_DELAY_IN_MS = 700;
//
// /**
// * minimal time between beacons for the same aircraft in MS
// */
// public static final int MINIMAL_AIRCRAFT_DIFF_TIME_IN_MS = 500;
//
// /**
// * action name for emergency exit intent
// */
// public static final String EMERGENCY_EXIT_INTENT_ACTION_NAME = "EMERGENCY_EXIT";
//
// /**
// * minimal value for coloration of altitude in meters
// */
// public static final float MIN_ALT_FOR_COLORATION = 500.0f;
//
// /**
// * maximal value for coloration of altitude in meters
// */
// public static final float MAX_ALT_FOR_COLORATION = 3000.0f;
//
// /**
// * default aprs filter radius in m
// */
// public static final float DEFAULT_APRS_FILTER_RADIUS = 100000.0f;
//
// }
| import android.annotation.SuppressLint;
import android.content.IntentFilter;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.meisterschueler.ognviewer.common.AppConstants; | package com.meisterschueler.ognviewer.activity.base;
@SuppressLint("Registered")
public class BaseActivity extends AppCompatActivity {
KillBroadcastReceiver killBroadcastReceiver;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
killBroadcastReceiver = new KillBroadcastReceiver(this); | // Path: app/src/main/java/com/meisterschueler/ognviewer/common/AppConstants.java
// public class AppConstants {
// // permission request codes (must be 0 to 65535 for AppCompat!)
// // so keep it unsigned short: https://stackoverflow.com/questions/33331073/android-what-to-choose-for-requestcode-values/33331459#33331459
// public static final int REQUEST_CODE_LOCATION_ZOOM = 54321;
// public static final int REQUEST_CODE_LOCATION_FILTER = 2468;
// public static final int REQUEST_CODE_LOCATION_TCP_UPDATES = 12341;
// public static final int REQUEST_CODE_LOCATION_TCP_UPDATES_FROM_SERVICE = 1234;
// public static final int REQUEST_CODE_STORAGE_IMPORT = 20201;
// public static final int REQUEST_CODE_STORAGE_EXPORT = 20202;
//
// // Intents
// public static final String INTENT_AIRCRAFT_BEACON = "AIRCRAFT-BEACON";
// public static final String INTENT_RECEIVER_BEACON = "RECEIVER-BEACON";
// public static final String INTENT_AIRCRAFT_ACTION = "AIRCRAFT_ACTION";
// public static final String INTENT_LOCATION = "LOCATION";
//
// /**
// * after this time inactive aircraft are removed
// */
// public static final int DEFAULT_AIRCRAFT_TIMEOUT_IN_SEC = 300;
//
// /**
// * zoom factor for "go to current location"
// */
// public static final int DEFAULT_MAP_ZOOM = 7;
//
// /**
// * request code for settings activity
// */
// public static final int ACTIVITY_REQUEST_CODE_SETTINGS = 2000;
//
// /**
// * TCP port for other apps to connect
// */
// public static final int TCP_SERVER_PORT = 4353;
//
// /**
// * REST API base url for flightpath
// */
// public static final String FLIGHTPATH_API_BASE_URL = "http://ogn.dominik-p.de:18820/api/";
//
// /**
// * restore markers after a little delay to prevent black screen issue
// */
// public static final int RESTORE_MAP_AFTER_DELAY_IN_MS = 700;
//
// /**
// * minimal time between beacons for the same aircraft in MS
// */
// public static final int MINIMAL_AIRCRAFT_DIFF_TIME_IN_MS = 500;
//
// /**
// * action name for emergency exit intent
// */
// public static final String EMERGENCY_EXIT_INTENT_ACTION_NAME = "EMERGENCY_EXIT";
//
// /**
// * minimal value for coloration of altitude in meters
// */
// public static final float MIN_ALT_FOR_COLORATION = 500.0f;
//
// /**
// * maximal value for coloration of altitude in meters
// */
// public static final float MAX_ALT_FOR_COLORATION = 3000.0f;
//
// /**
// * default aprs filter radius in m
// */
// public static final float DEFAULT_APRS_FILTER_RADIUS = 100000.0f;
//
// }
// Path: app/src/main/java/com/meisterschueler/ognviewer/activity/base/BaseActivity.java
import android.annotation.SuppressLint;
import android.content.IntentFilter;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.meisterschueler.ognviewer.common.AppConstants;
package com.meisterschueler.ognviewer.activity.base;
@SuppressLint("Registered")
public class BaseActivity extends AppCompatActivity {
KillBroadcastReceiver killBroadcastReceiver;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
killBroadcastReceiver = new KillBroadcastReceiver(this); | registerReceiver(killBroadcastReceiver, new IntentFilter(AppConstants.EMERGENCY_EXIT_INTENT_ACTION_NAME)); |
jankotek/JDBM3 | src/main/java/org/apache/jdbm/PhysicalRowIdManager.java | // Path: src/main/java/org/apache/jdbm/Storage.java
// interface Storage {
//
// /**
// * Bite shift used to calculate page size.
// * If you want to modify page size, do it here.
// *
// * 1<<9 = 512
// * 1<<10 = 1024
// * 1<<11 = 2048
// * 1<<12 = 4096
// */
// int PAGE_SIZE_SHIFT = 12;
//
// /**
// * the lenght of single page.
// * <p>
// *!!! DO NOT MODIFY THI DIRECTLY !!!
//
// */
// int PAGE_SIZE = 1<< PAGE_SIZE_SHIFT;
//
//
// /**
// * use 'val & OFFSET_MASK' to quickly get offset within the page;
// */
// long OFFSET_MASK = 0xFFFFFFFFFFFFFFFFL >>> (64-Storage.PAGE_SIZE_SHIFT);
//
//
// void write(long pageNumber, ByteBuffer data) throws IOException;
//
// ByteBuffer read(long pageNumber) throws IOException;
//
// void forceClose() throws IOException;
//
// boolean isReadonly();
//
// DataInputStream readTransactionLog();
//
// void deleteTransactionLog();
//
// void sync() throws IOException;
//
// DataOutputStream openTransactionLog() throws IOException;
//
// void deleteAllFiles() throws IOException;
// }
| import java.io.IOException;
import static org.apache.jdbm.Storage.*; | /*******************************************************************************
* Copyright 2010 Cees De Groot, Alex Boisvert, Jan Kotek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.apache.jdbm;
/**
* This class manages physical row ids, and their data.
*/
final class PhysicalRowIdManager {
// The file we're talking to and the associated page manager.
final private PageFile file;
final private PageManager pageman;
final PhysicalFreeRowIdManager freeman;
static final private short DATA_PER_PAGE = (short) (PAGE_SIZE - Magic.DATA_PAGE_O_DATA);
//caches offset after last allocation. So we dont have to iterate throw page every allocation
private long cachedLastAllocatedRecordPage = Long.MIN_VALUE;
private short cachedLastAllocatedRecordOffset = Short.MIN_VALUE;
/**
* Creates a new rowid manager using the indicated record file. and page manager.
*/
PhysicalRowIdManager(PageFile file, PageManager pageManager) throws IOException {
this.file = file;
this.pageman = pageManager;
this.freeman = new PhysicalFreeRowIdManager(file, pageManager);
}
/**
* Inserts a new record. Returns the new physical rowid.
*/
long insert(final byte[] data, final int start, final int length) throws IOException {
if (length < 1)
throw new IllegalArgumentException("Length is <1");
if (start < 0)
throw new IllegalArgumentException("negative start");
long retval = alloc(length);
write(retval, data, start, length);
return retval;
}
/**
* Updates an existing record. Returns the possibly changed physical rowid.
*/
long update(long rowid, final byte[] data, final int start, final int length) throws IOException {
// fetch the record header | // Path: src/main/java/org/apache/jdbm/Storage.java
// interface Storage {
//
// /**
// * Bite shift used to calculate page size.
// * If you want to modify page size, do it here.
// *
// * 1<<9 = 512
// * 1<<10 = 1024
// * 1<<11 = 2048
// * 1<<12 = 4096
// */
// int PAGE_SIZE_SHIFT = 12;
//
// /**
// * the lenght of single page.
// * <p>
// *!!! DO NOT MODIFY THI DIRECTLY !!!
//
// */
// int PAGE_SIZE = 1<< PAGE_SIZE_SHIFT;
//
//
// /**
// * use 'val & OFFSET_MASK' to quickly get offset within the page;
// */
// long OFFSET_MASK = 0xFFFFFFFFFFFFFFFFL >>> (64-Storage.PAGE_SIZE_SHIFT);
//
//
// void write(long pageNumber, ByteBuffer data) throws IOException;
//
// ByteBuffer read(long pageNumber) throws IOException;
//
// void forceClose() throws IOException;
//
// boolean isReadonly();
//
// DataInputStream readTransactionLog();
//
// void deleteTransactionLog();
//
// void sync() throws IOException;
//
// DataOutputStream openTransactionLog() throws IOException;
//
// void deleteAllFiles() throws IOException;
// }
// Path: src/main/java/org/apache/jdbm/PhysicalRowIdManager.java
import java.io.IOException;
import static org.apache.jdbm.Storage.*;
/*******************************************************************************
* Copyright 2010 Cees De Groot, Alex Boisvert, Jan Kotek
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.apache.jdbm;
/**
* This class manages physical row ids, and their data.
*/
final class PhysicalRowIdManager {
// The file we're talking to and the associated page manager.
final private PageFile file;
final private PageManager pageman;
final PhysicalFreeRowIdManager freeman;
static final private short DATA_PER_PAGE = (short) (PAGE_SIZE - Magic.DATA_PAGE_O_DATA);
//caches offset after last allocation. So we dont have to iterate throw page every allocation
private long cachedLastAllocatedRecordPage = Long.MIN_VALUE;
private short cachedLastAllocatedRecordOffset = Short.MIN_VALUE;
/**
* Creates a new rowid manager using the indicated record file. and page manager.
*/
PhysicalRowIdManager(PageFile file, PageManager pageManager) throws IOException {
this.file = file;
this.pageman = pageManager;
this.freeman = new PhysicalFreeRowIdManager(file, pageManager);
}
/**
* Inserts a new record. Returns the new physical rowid.
*/
long insert(final byte[] data, final int start, final int length) throws IOException {
if (length < 1)
throw new IllegalArgumentException("Length is <1");
if (start < 0)
throw new IllegalArgumentException("negative start");
long retval = alloc(length);
write(retval, data, start, length);
return retval;
}
/**
* Updates an existing record. Returns the possibly changed physical rowid.
*/
long update(long rowid, final byte[] data, final int start, final int length) throws IOException {
// fetch the record header | PageIo page = file.get(rowid>>> Storage.PAGE_SIZE_SHIFT); |
jankotek/JDBM3 | src/main/java/org/apache/jdbm/SerialClassInfo.java | // Path: src/main/java/org/apache/jdbm/Serialization.java
// static class FastArrayList<K> {
//
// private int size = 0;
// private K[] elementData = (K[]) new Object[8];
//
// K get(int index) {
// if (index >= size) throw new IndexOutOfBoundsException();
// return elementData[index];
// }
//
// void add(K o) {
// if (elementData.length == size) {
// //grow array if necessary
// elementData = Arrays.copyOf(elementData, elementData.length * 2);
// }
//
// elementData[size] = o;
// size++;
// }
//
// int size() {
// return size;
// }
//
//
// /**
// * This method is reason why ArrayList is not used.
// * Search an item in list and returns its index.
// * It uses identity rather than 'equalsTo'
// * One could argue that TreeMap should be used instead,
// * but we do not expect large object trees.
// * This search is VERY FAST compared to Maps, it does not allocate
// * new instances or uses method calls.
// *
// * @param obj
// * @return index of object in list or -1 if not found
// */
// int identityIndexOf(Object obj) {
// for (int i = 0; i < size; i++) {
// if (obj == elementData[i])
// return i;
// }
// return -1;
// }
//
// }
| import org.apache.jdbm.Serialization.FastArrayList;
import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | return;
ObjectStreamField[] streamFields = getFields(clazz);
FieldInfo[] fields = new FieldInfo[streamFields.length];
for (int i = 0; i < fields.length; i++) {
ObjectStreamField sf = streamFields[i];
fields[i] = new FieldInfo(sf, clazz);
}
ClassInfo i = new ClassInfo(clazz.getName(), fields,clazz.isEnum(), Externalizable.class.isAssignableFrom(clazz));
class2classId.put(clazz, registered.size());
classId2class.put(registered.size(), clazz);
registered.add(i);
if (db != null)
db.update(serialClassInfoRecid, (Serialization) this, db.defaultSerializationSerializer);
}
private ObjectStreamField[] getFields(Class clazz) {
ObjectStreamField[] fields = null;
ClassInfo classInfo = null;
Integer classId = class2classId.get(clazz);
if (classId != null) {
classInfo = registered.get(classId);
fields = classInfo.getObjectStreamFields();
}
if (fields == null) {
ObjectStreamClass streamClass = ObjectStreamClass.lookup(clazz); | // Path: src/main/java/org/apache/jdbm/Serialization.java
// static class FastArrayList<K> {
//
// private int size = 0;
// private K[] elementData = (K[]) new Object[8];
//
// K get(int index) {
// if (index >= size) throw new IndexOutOfBoundsException();
// return elementData[index];
// }
//
// void add(K o) {
// if (elementData.length == size) {
// //grow array if necessary
// elementData = Arrays.copyOf(elementData, elementData.length * 2);
// }
//
// elementData[size] = o;
// size++;
// }
//
// int size() {
// return size;
// }
//
//
// /**
// * This method is reason why ArrayList is not used.
// * Search an item in list and returns its index.
// * It uses identity rather than 'equalsTo'
// * One could argue that TreeMap should be used instead,
// * but we do not expect large object trees.
// * This search is VERY FAST compared to Maps, it does not allocate
// * new instances or uses method calls.
// *
// * @param obj
// * @return index of object in list or -1 if not found
// */
// int identityIndexOf(Object obj) {
// for (int i = 0; i < size; i++) {
// if (obj == elementData[i])
// return i;
// }
// return -1;
// }
//
// }
// Path: src/main/java/org/apache/jdbm/SerialClassInfo.java
import org.apache.jdbm.Serialization.FastArrayList;
import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
return;
ObjectStreamField[] streamFields = getFields(clazz);
FieldInfo[] fields = new FieldInfo[streamFields.length];
for (int i = 0; i < fields.length; i++) {
ObjectStreamField sf = streamFields[i];
fields[i] = new FieldInfo(sf, clazz);
}
ClassInfo i = new ClassInfo(clazz.getName(), fields,clazz.isEnum(), Externalizable.class.isAssignableFrom(clazz));
class2classId.put(clazz, registered.size());
classId2class.put(registered.size(), clazz);
registered.add(i);
if (db != null)
db.update(serialClassInfoRecid, (Serialization) this, db.defaultSerializationSerializer);
}
private ObjectStreamField[] getFields(Class clazz) {
ObjectStreamField[] fields = null;
ClassInfo classInfo = null;
Integer classId = class2classId.get(clazz);
if (classId != null) {
classInfo = registered.get(classId);
fields = classInfo.getObjectStreamFields();
}
if (fields == null) {
ObjectStreamClass streamClass = ObjectStreamClass.lookup(clazz); | FastArrayList<ObjectStreamField> fieldsList = new FastArrayList<ObjectStreamField>(); |
jankotek/JDBM3 | src/main/java/org/apache/jdbm/PageIo.java | // Path: src/main/java/org/apache/jdbm/Magic.java
// interface Magic {
// /**
// * Magic cookie at start of file
// */
// short FILE_HEADER = 0x1350;
//
// /**
// * Magic for pages. They're offset by the page type magic codes.
// */
// short PAGE_MAGIC = 0x1351;
//
// /**
// * Magics for pages in certain lists.
// */
// short FREE_PAGE = 0;
// short USED_PAGE = 1;
// short TRANSLATION_PAGE = 2;
// short FREELOGIDS_PAGE = 3;
// short FREEPHYSIDS_PAGE = 4;
// short FREEPHYSIDS_ROOT_PAGE = 5;
//
// /**
// * Number of lists in a file
// */
// short NLISTS = 6;
//
// /**
// * Magic for transaction file
// */
// short LOGFILE_HEADER = 0x1360;
//
// /**
// * Size of an externalized byte
// */
// short SZ_BYTE = 1;
// /**
// * Size of an externalized short
// */
// short SZ_SHORT = 2;
//
// /**
// * Size of an externalized int
// */
// short SZ_INT = 4;
// /**
// * Size of an externalized long
// */
// short SZ_LONG = 8;
//
// /**
// * size of three byte integer
// */
// short SZ_SIX_BYTE_LONG = 6;
//
//
// /**offsets in file header (zero page in file)*/
// short FILE_HEADER_O_MAGIC = 0; // short magic
// short FILE_HEADER_O_LISTS = Magic.SZ_SHORT; // long[2*NLISTS]
// int FILE_HEADER_O_ROOTS = FILE_HEADER_O_LISTS + (Magic.NLISTS * 2 * Magic.SZ_LONG);
// /**
// * The number of "root" rowids available in the file.
// */
// int FILE_HEADER_NROOTS = 16;
//
//
// short PAGE_HEADER_O_MAGIC = 0; // short magic
// short PAGE_HEADER_O_NEXT = Magic.SZ_SHORT;
// short PAGE_HEADER_O_PREV = PAGE_HEADER_O_NEXT + Magic.SZ_SIX_BYTE_LONG;
// short PAGE_HEADER_SIZE = PAGE_HEADER_O_PREV + Magic.SZ_SIX_BYTE_LONG;
//
// short PhysicalRowId_O_LOCATION = 0; // long page
// // short PhysicalRowId_O_OFFSET = Magic.SZ_SIX_BYTE_LONG; // short offset
// int PhysicalRowId_SIZE = Magic.SZ_SIX_BYTE_LONG;
//
// short DATA_PAGE_O_FIRST = PAGE_HEADER_SIZE; // short firstrowid
// short DATA_PAGE_O_DATA = (short) (DATA_PAGE_O_FIRST + Magic.SZ_SHORT);
// short DATA_PER_PAGE = (short) (Storage.PAGE_SIZE - DATA_PAGE_O_DATA);
//
//
//
//
//
//
// }
| import javax.crypto.Cipher;
import java.io.*;
import java.nio.ByteBuffer;
import static org.apache.jdbm.Magic.*; | } catch (Exception e) {
throw new IOError(e);
}
}
public void writeExternal(DataOutput out, Cipher cipherIn) throws IOException {
out.writeLong(pageId);
out.write(Utils.encrypt(cipherIn, data.array()));
}
public byte[] getByteArray() {
if ( data.hasArray())
return data.array();
byte[] d= new byte[Storage.PAGE_SIZE];
data.rewind();
data.get(d,0,Storage.PAGE_SIZE);
return d;
}
public void writeByteArray(byte[] buf, int srcOffset, int offset, int length) {
setDirty();
data.rewind();
data.position(offset);
data.put(buf,srcOffset,length);
}
public void fileHeaderCheckHead(boolean isNew){
if (isNew) | // Path: src/main/java/org/apache/jdbm/Magic.java
// interface Magic {
// /**
// * Magic cookie at start of file
// */
// short FILE_HEADER = 0x1350;
//
// /**
// * Magic for pages. They're offset by the page type magic codes.
// */
// short PAGE_MAGIC = 0x1351;
//
// /**
// * Magics for pages in certain lists.
// */
// short FREE_PAGE = 0;
// short USED_PAGE = 1;
// short TRANSLATION_PAGE = 2;
// short FREELOGIDS_PAGE = 3;
// short FREEPHYSIDS_PAGE = 4;
// short FREEPHYSIDS_ROOT_PAGE = 5;
//
// /**
// * Number of lists in a file
// */
// short NLISTS = 6;
//
// /**
// * Magic for transaction file
// */
// short LOGFILE_HEADER = 0x1360;
//
// /**
// * Size of an externalized byte
// */
// short SZ_BYTE = 1;
// /**
// * Size of an externalized short
// */
// short SZ_SHORT = 2;
//
// /**
// * Size of an externalized int
// */
// short SZ_INT = 4;
// /**
// * Size of an externalized long
// */
// short SZ_LONG = 8;
//
// /**
// * size of three byte integer
// */
// short SZ_SIX_BYTE_LONG = 6;
//
//
// /**offsets in file header (zero page in file)*/
// short FILE_HEADER_O_MAGIC = 0; // short magic
// short FILE_HEADER_O_LISTS = Magic.SZ_SHORT; // long[2*NLISTS]
// int FILE_HEADER_O_ROOTS = FILE_HEADER_O_LISTS + (Magic.NLISTS * 2 * Magic.SZ_LONG);
// /**
// * The number of "root" rowids available in the file.
// */
// int FILE_HEADER_NROOTS = 16;
//
//
// short PAGE_HEADER_O_MAGIC = 0; // short magic
// short PAGE_HEADER_O_NEXT = Magic.SZ_SHORT;
// short PAGE_HEADER_O_PREV = PAGE_HEADER_O_NEXT + Magic.SZ_SIX_BYTE_LONG;
// short PAGE_HEADER_SIZE = PAGE_HEADER_O_PREV + Magic.SZ_SIX_BYTE_LONG;
//
// short PhysicalRowId_O_LOCATION = 0; // long page
// // short PhysicalRowId_O_OFFSET = Magic.SZ_SIX_BYTE_LONG; // short offset
// int PhysicalRowId_SIZE = Magic.SZ_SIX_BYTE_LONG;
//
// short DATA_PAGE_O_FIRST = PAGE_HEADER_SIZE; // short firstrowid
// short DATA_PAGE_O_DATA = (short) (DATA_PAGE_O_FIRST + Magic.SZ_SHORT);
// short DATA_PER_PAGE = (short) (Storage.PAGE_SIZE - DATA_PAGE_O_DATA);
//
//
//
//
//
//
// }
// Path: src/main/java/org/apache/jdbm/PageIo.java
import javax.crypto.Cipher;
import java.io.*;
import java.nio.ByteBuffer;
import static org.apache.jdbm.Magic.*;
} catch (Exception e) {
throw new IOError(e);
}
}
public void writeExternal(DataOutput out, Cipher cipherIn) throws IOException {
out.writeLong(pageId);
out.write(Utils.encrypt(cipherIn, data.array()));
}
public byte[] getByteArray() {
if ( data.hasArray())
return data.array();
byte[] d= new byte[Storage.PAGE_SIZE];
data.rewind();
data.get(d,0,Storage.PAGE_SIZE);
return d;
}
public void writeByteArray(byte[] buf, int srcOffset, int offset, int length) {
setDirty();
data.rewind();
data.position(offset);
data.put(buf,srcOffset,length);
}
public void fileHeaderCheckHead(boolean isNew){
if (isNew) | writeShort(FILE_HEADER_O_MAGIC, Magic.FILE_HEADER); |
lkorth/photo-paper | PhotoPaper/src/main/java/com/lukekorth/photo_paper/RecentPhotosActivity.java | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/RecentPhotosAdapter.java
// public class RecentPhotosAdapter extends RecyclerView.Adapter<RecentPhotosAdapter.ViewHolder> {
//
// private List<Photos> mPhotos;
// private Picasso mPicasso;
// private int mSize;
//
// public RecentPhotosAdapter(Context context, Realm realm) {
// mPhotos = Photos.getRecentlySeenPhotos(realm);
// mPicasso = PicassoHelper.getPicasso(context);
// mSize = Utils.dpToPx(context, 100);
// }
//
// @Override
// public RecentPhotosAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// PhotoCardBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()),
// R.layout.photo_card, parent, false);
// return new ViewHolder(binding);
// }
//
// @Override
// public void onBindViewHolder(ViewHolder holder, int position) {
// final Photos photo = mPhotos.get(position);
// holder.mBinding.setPhoto(photo);
// mPicasso.load(photo.imageUrl)
// .resize(mSize, mSize)
// .centerCrop()
// .placeholder(new ColorDrawable(photo.getPalette()))
// .into(holder.mBinding.thumbnail);
// }
//
// @Override
// public int getItemCount() {
// return mPhotos.size();
// }
//
// static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
//
// private PhotoCardBinding mBinding;
//
// ViewHolder(PhotoCardBinding binding) {
// super(binding.getRoot());
// mBinding = binding;
// itemView.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(v.getContext(), ViewPhotoActivity.class)
// .putExtra(ViewPhotoActivity.PHOTO_POSITION_KEY, getPosition());
// v.getContext().startActivity(intent);
// }
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/WallpaperChangedEvent.java
// public class WallpaperChangedEvent {
// }
| import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import com.lukekorth.photo_paper.adapters.RecentPhotosAdapter;
import com.lukekorth.photo_paper.models.WallpaperChangedEvent;
import com.squareup.otto.Subscribe;
import io.realm.Realm; | package com.lukekorth.photo_paper;
public class RecentPhotosActivity extends AppCompatActivity {
private Realm mRealm;
private RecyclerView mRecyclerView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.recent_photos);
mRealm = Realm.getDefaultInstance();
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/RecentPhotosAdapter.java
// public class RecentPhotosAdapter extends RecyclerView.Adapter<RecentPhotosAdapter.ViewHolder> {
//
// private List<Photos> mPhotos;
// private Picasso mPicasso;
// private int mSize;
//
// public RecentPhotosAdapter(Context context, Realm realm) {
// mPhotos = Photos.getRecentlySeenPhotos(realm);
// mPicasso = PicassoHelper.getPicasso(context);
// mSize = Utils.dpToPx(context, 100);
// }
//
// @Override
// public RecentPhotosAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// PhotoCardBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()),
// R.layout.photo_card, parent, false);
// return new ViewHolder(binding);
// }
//
// @Override
// public void onBindViewHolder(ViewHolder holder, int position) {
// final Photos photo = mPhotos.get(position);
// holder.mBinding.setPhoto(photo);
// mPicasso.load(photo.imageUrl)
// .resize(mSize, mSize)
// .centerCrop()
// .placeholder(new ColorDrawable(photo.getPalette()))
// .into(holder.mBinding.thumbnail);
// }
//
// @Override
// public int getItemCount() {
// return mPhotos.size();
// }
//
// static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
//
// private PhotoCardBinding mBinding;
//
// ViewHolder(PhotoCardBinding binding) {
// super(binding.getRoot());
// mBinding = binding;
// itemView.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(v.getContext(), ViewPhotoActivity.class)
// .putExtra(ViewPhotoActivity.PHOTO_POSITION_KEY, getPosition());
// v.getContext().startActivity(intent);
// }
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/WallpaperChangedEvent.java
// public class WallpaperChangedEvent {
// }
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/RecentPhotosActivity.java
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import com.lukekorth.photo_paper.adapters.RecentPhotosAdapter;
import com.lukekorth.photo_paper.models.WallpaperChangedEvent;
import com.squareup.otto.Subscribe;
import io.realm.Realm;
package com.lukekorth.photo_paper;
public class RecentPhotosActivity extends AppCompatActivity {
private Realm mRealm;
private RecyclerView mRecyclerView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.recent_photos);
mRealm = Realm.getDefaultInstance();
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); | mRecyclerView.setAdapter(new RecentPhotosAdapter(this, mRealm)); |
lkorth/photo-paper | PhotoPaper/src/main/java/com/lukekorth/photo_paper/RecentPhotosActivity.java | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/RecentPhotosAdapter.java
// public class RecentPhotosAdapter extends RecyclerView.Adapter<RecentPhotosAdapter.ViewHolder> {
//
// private List<Photos> mPhotos;
// private Picasso mPicasso;
// private int mSize;
//
// public RecentPhotosAdapter(Context context, Realm realm) {
// mPhotos = Photos.getRecentlySeenPhotos(realm);
// mPicasso = PicassoHelper.getPicasso(context);
// mSize = Utils.dpToPx(context, 100);
// }
//
// @Override
// public RecentPhotosAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// PhotoCardBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()),
// R.layout.photo_card, parent, false);
// return new ViewHolder(binding);
// }
//
// @Override
// public void onBindViewHolder(ViewHolder holder, int position) {
// final Photos photo = mPhotos.get(position);
// holder.mBinding.setPhoto(photo);
// mPicasso.load(photo.imageUrl)
// .resize(mSize, mSize)
// .centerCrop()
// .placeholder(new ColorDrawable(photo.getPalette()))
// .into(holder.mBinding.thumbnail);
// }
//
// @Override
// public int getItemCount() {
// return mPhotos.size();
// }
//
// static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
//
// private PhotoCardBinding mBinding;
//
// ViewHolder(PhotoCardBinding binding) {
// super(binding.getRoot());
// mBinding = binding;
// itemView.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(v.getContext(), ViewPhotoActivity.class)
// .putExtra(ViewPhotoActivity.PHOTO_POSITION_KEY, getPosition());
// v.getContext().startActivity(intent);
// }
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/WallpaperChangedEvent.java
// public class WallpaperChangedEvent {
// }
| import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import com.lukekorth.photo_paper.adapters.RecentPhotosAdapter;
import com.lukekorth.photo_paper.models.WallpaperChangedEvent;
import com.squareup.otto.Subscribe;
import io.realm.Realm; |
mRealm = Realm.getDefaultInstance();
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setAdapter(new RecentPhotosAdapter(this, mRealm));
WallpaperApplication.getBus().register(this);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
@Override
protected void onResume() {
super.onResume();
onWallpaperChanged(null);
}
@Override
protected void onDestroy() {
super.onDestroy();
WallpaperApplication.getBus().unregister(this);
mRealm.close();
}
@Subscribe | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/RecentPhotosAdapter.java
// public class RecentPhotosAdapter extends RecyclerView.Adapter<RecentPhotosAdapter.ViewHolder> {
//
// private List<Photos> mPhotos;
// private Picasso mPicasso;
// private int mSize;
//
// public RecentPhotosAdapter(Context context, Realm realm) {
// mPhotos = Photos.getRecentlySeenPhotos(realm);
// mPicasso = PicassoHelper.getPicasso(context);
// mSize = Utils.dpToPx(context, 100);
// }
//
// @Override
// public RecentPhotosAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// PhotoCardBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()),
// R.layout.photo_card, parent, false);
// return new ViewHolder(binding);
// }
//
// @Override
// public void onBindViewHolder(ViewHolder holder, int position) {
// final Photos photo = mPhotos.get(position);
// holder.mBinding.setPhoto(photo);
// mPicasso.load(photo.imageUrl)
// .resize(mSize, mSize)
// .centerCrop()
// .placeholder(new ColorDrawable(photo.getPalette()))
// .into(holder.mBinding.thumbnail);
// }
//
// @Override
// public int getItemCount() {
// return mPhotos.size();
// }
//
// static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
//
// private PhotoCardBinding mBinding;
//
// ViewHolder(PhotoCardBinding binding) {
// super(binding.getRoot());
// mBinding = binding;
// itemView.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(v.getContext(), ViewPhotoActivity.class)
// .putExtra(ViewPhotoActivity.PHOTO_POSITION_KEY, getPosition());
// v.getContext().startActivity(intent);
// }
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/WallpaperChangedEvent.java
// public class WallpaperChangedEvent {
// }
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/RecentPhotosActivity.java
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import com.lukekorth.photo_paper.adapters.RecentPhotosAdapter;
import com.lukekorth.photo_paper.models.WallpaperChangedEvent;
import com.squareup.otto.Subscribe;
import io.realm.Realm;
mRealm = Realm.getDefaultInstance();
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setAdapter(new RecentPhotosAdapter(this, mRealm));
WallpaperApplication.getBus().register(this);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
@Override
protected void onResume() {
super.onResume();
onWallpaperChanged(null);
}
@Override
protected void onDestroy() {
super.onDestroy();
WallpaperApplication.getBus().unregister(this);
mRealm.close();
}
@Subscribe | public void onWallpaperChanged(WallpaperChangedEvent event) { |
lkorth/photo-paper | PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/GridPhotoAdapter.java | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/PicassoHelper.java
// public class PicassoHelper {
//
// public static Picasso getPicasso(Context context) {
// return new Picasso.Builder(context.getApplicationContext())
// .downloader(new OkHttp3Downloader(context.getApplicationContext(), 512000000)) // 512mb
// .indicatorsEnabled(BuildConfig.DEBUG)
// .build();
// }
//
// public static void clearCache(Context context) {
// PicassoTools.clearCache(PicassoHelper.getPicasso(context));
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/Utils.java
// public class Utils {
//
// public static boolean shouldGetPhotos(Context context, Realm realm) {
// return Settings.isEnabled(context) && Utils.needMorePhotos(context, realm) &&
// isCurrentNetworkOk(context);
// }
//
// public static boolean shouldUpdateWallpaper(Context context) {
// return Settings.isEnabled(context) && (((Settings.getLastUpdated(context) +
// (Settings.getUpdateInterval(context) * 1000)) < System.currentTimeMillis()));
// }
//
// public static boolean isCurrentNetworkOk(Context context) {
// return !Settings.useOnlyWifi(context) ||
// (Settings.useOnlyWifi(context) && Utils.isConnectedToWifi(context));
// }
//
// public static boolean needMorePhotos(Context context, Realm realm) {
// return Photos.unseenPhotoCount(context, realm) <= 10;
// }
//
// public static boolean isConnectedToWifi(Context context) {
// ConnectivityManager connectivityManager =
// (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
// return (activeNetwork != null && activeNetwork.isConnectedOrConnecting() &&
// activeNetwork.getType() == ConnectivityManager.TYPE_WIFI);
// }
//
// public static int dpToPx(Context context, double dp) {
// return (int) Math.round(dp * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
// }
//
// public static int getWallpaperHeight(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumHeight();
// }
//
// public static int getWallpaperWidth(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumWidth();
// }
//
// public static int getScreenHeight(Context context) {
// return getScreenResolution(context).y;
// }
//
// public static int getScreenWidth(Context context) {
// return getScreenResolution(context).x;
// }
//
// private static Point getScreenResolution(Context context) {
// WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Point point = new Point();
// windowManager.getDefaultDisplay().getSize(point);
// return point;
// }
//
// public static boolean supportsParallax(Context context) {
// return ((double) getWallpaperWidth(context) / getScreenWidth(context)) >= 2;
// }
//
// public static String getListSummary(Context context, int indexArrayId, int valueArrayId,
// String index, String defaultValue) {
// String[] indexArray = context.getResources().getStringArray(indexArrayId);
// String[] valueArray = context.getResources().getStringArray(valueArrayId);
// int i;
// for (i = 0; i < indexArray.length; i++) {
// if (indexArray[i].equals(index)) {
// return valueArray[i];
// }
// }
// return defaultValue;
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/Photo.java
// public class Photo {
//
// @Expose public String id;
// @Expose public String name;
// @Expose public String description;
// @Expose @SerializedName("created_at") public String createdAt;
// @Expose public int category;
// @Expose @SerializedName("votes_count") public int votes;
// @Expose public boolean nsfw;
// @Expose @SerializedName("highest_rating") public double highestRating;
// @Expose @SerializedName("times_viewed") public int views;
// @Expose @SerializedName("image_url") public String imageUrl;
// @Expose public String url;
// @Expose public User user;
// @Expose public boolean voted;
// @Expose public boolean favorited;
//
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/views/SquareImageView.java
// public class SquareImageView extends ImageView {
//
// public SquareImageView(Context context) {
// super(context);
// }
//
// public SquareImageView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
// }
// }
| import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.lukekorth.photo_paper.R;
import com.lukekorth.photo_paper.helpers.PicassoHelper;
import com.lukekorth.photo_paper.helpers.Utils;
import com.lukekorth.photo_paper.models.Photo;
import com.lukekorth.photo_paper.views.SquareImageView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import static android.widget.ImageView.ScaleType.CENTER_CROP; | package com.lukekorth.photo_paper.adapters;
public class GridPhotoAdapter extends BaseAdapter {
public static final String TAG = "GridPhotoAdapter";
private Context mContext; | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/PicassoHelper.java
// public class PicassoHelper {
//
// public static Picasso getPicasso(Context context) {
// return new Picasso.Builder(context.getApplicationContext())
// .downloader(new OkHttp3Downloader(context.getApplicationContext(), 512000000)) // 512mb
// .indicatorsEnabled(BuildConfig.DEBUG)
// .build();
// }
//
// public static void clearCache(Context context) {
// PicassoTools.clearCache(PicassoHelper.getPicasso(context));
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/Utils.java
// public class Utils {
//
// public static boolean shouldGetPhotos(Context context, Realm realm) {
// return Settings.isEnabled(context) && Utils.needMorePhotos(context, realm) &&
// isCurrentNetworkOk(context);
// }
//
// public static boolean shouldUpdateWallpaper(Context context) {
// return Settings.isEnabled(context) && (((Settings.getLastUpdated(context) +
// (Settings.getUpdateInterval(context) * 1000)) < System.currentTimeMillis()));
// }
//
// public static boolean isCurrentNetworkOk(Context context) {
// return !Settings.useOnlyWifi(context) ||
// (Settings.useOnlyWifi(context) && Utils.isConnectedToWifi(context));
// }
//
// public static boolean needMorePhotos(Context context, Realm realm) {
// return Photos.unseenPhotoCount(context, realm) <= 10;
// }
//
// public static boolean isConnectedToWifi(Context context) {
// ConnectivityManager connectivityManager =
// (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
// return (activeNetwork != null && activeNetwork.isConnectedOrConnecting() &&
// activeNetwork.getType() == ConnectivityManager.TYPE_WIFI);
// }
//
// public static int dpToPx(Context context, double dp) {
// return (int) Math.round(dp * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
// }
//
// public static int getWallpaperHeight(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumHeight();
// }
//
// public static int getWallpaperWidth(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumWidth();
// }
//
// public static int getScreenHeight(Context context) {
// return getScreenResolution(context).y;
// }
//
// public static int getScreenWidth(Context context) {
// return getScreenResolution(context).x;
// }
//
// private static Point getScreenResolution(Context context) {
// WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Point point = new Point();
// windowManager.getDefaultDisplay().getSize(point);
// return point;
// }
//
// public static boolean supportsParallax(Context context) {
// return ((double) getWallpaperWidth(context) / getScreenWidth(context)) >= 2;
// }
//
// public static String getListSummary(Context context, int indexArrayId, int valueArrayId,
// String index, String defaultValue) {
// String[] indexArray = context.getResources().getStringArray(indexArrayId);
// String[] valueArray = context.getResources().getStringArray(valueArrayId);
// int i;
// for (i = 0; i < indexArray.length; i++) {
// if (indexArray[i].equals(index)) {
// return valueArray[i];
// }
// }
// return defaultValue;
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/Photo.java
// public class Photo {
//
// @Expose public String id;
// @Expose public String name;
// @Expose public String description;
// @Expose @SerializedName("created_at") public String createdAt;
// @Expose public int category;
// @Expose @SerializedName("votes_count") public int votes;
// @Expose public boolean nsfw;
// @Expose @SerializedName("highest_rating") public double highestRating;
// @Expose @SerializedName("times_viewed") public int views;
// @Expose @SerializedName("image_url") public String imageUrl;
// @Expose public String url;
// @Expose public User user;
// @Expose public boolean voted;
// @Expose public boolean favorited;
//
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/views/SquareImageView.java
// public class SquareImageView extends ImageView {
//
// public SquareImageView(Context context) {
// super(context);
// }
//
// public SquareImageView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
// }
// }
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/GridPhotoAdapter.java
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.lukekorth.photo_paper.R;
import com.lukekorth.photo_paper.helpers.PicassoHelper;
import com.lukekorth.photo_paper.helpers.Utils;
import com.lukekorth.photo_paper.models.Photo;
import com.lukekorth.photo_paper.views.SquareImageView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import static android.widget.ImageView.ScaleType.CENTER_CROP;
package com.lukekorth.photo_paper.adapters;
public class GridPhotoAdapter extends BaseAdapter {
public static final String TAG = "GridPhotoAdapter";
private Context mContext; | private List<Photo> mPhotos; |
lkorth/photo-paper | PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/GridPhotoAdapter.java | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/PicassoHelper.java
// public class PicassoHelper {
//
// public static Picasso getPicasso(Context context) {
// return new Picasso.Builder(context.getApplicationContext())
// .downloader(new OkHttp3Downloader(context.getApplicationContext(), 512000000)) // 512mb
// .indicatorsEnabled(BuildConfig.DEBUG)
// .build();
// }
//
// public static void clearCache(Context context) {
// PicassoTools.clearCache(PicassoHelper.getPicasso(context));
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/Utils.java
// public class Utils {
//
// public static boolean shouldGetPhotos(Context context, Realm realm) {
// return Settings.isEnabled(context) && Utils.needMorePhotos(context, realm) &&
// isCurrentNetworkOk(context);
// }
//
// public static boolean shouldUpdateWallpaper(Context context) {
// return Settings.isEnabled(context) && (((Settings.getLastUpdated(context) +
// (Settings.getUpdateInterval(context) * 1000)) < System.currentTimeMillis()));
// }
//
// public static boolean isCurrentNetworkOk(Context context) {
// return !Settings.useOnlyWifi(context) ||
// (Settings.useOnlyWifi(context) && Utils.isConnectedToWifi(context));
// }
//
// public static boolean needMorePhotos(Context context, Realm realm) {
// return Photos.unseenPhotoCount(context, realm) <= 10;
// }
//
// public static boolean isConnectedToWifi(Context context) {
// ConnectivityManager connectivityManager =
// (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
// return (activeNetwork != null && activeNetwork.isConnectedOrConnecting() &&
// activeNetwork.getType() == ConnectivityManager.TYPE_WIFI);
// }
//
// public static int dpToPx(Context context, double dp) {
// return (int) Math.round(dp * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
// }
//
// public static int getWallpaperHeight(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumHeight();
// }
//
// public static int getWallpaperWidth(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumWidth();
// }
//
// public static int getScreenHeight(Context context) {
// return getScreenResolution(context).y;
// }
//
// public static int getScreenWidth(Context context) {
// return getScreenResolution(context).x;
// }
//
// private static Point getScreenResolution(Context context) {
// WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Point point = new Point();
// windowManager.getDefaultDisplay().getSize(point);
// return point;
// }
//
// public static boolean supportsParallax(Context context) {
// return ((double) getWallpaperWidth(context) / getScreenWidth(context)) >= 2;
// }
//
// public static String getListSummary(Context context, int indexArrayId, int valueArrayId,
// String index, String defaultValue) {
// String[] indexArray = context.getResources().getStringArray(indexArrayId);
// String[] valueArray = context.getResources().getStringArray(valueArrayId);
// int i;
// for (i = 0; i < indexArray.length; i++) {
// if (indexArray[i].equals(index)) {
// return valueArray[i];
// }
// }
// return defaultValue;
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/Photo.java
// public class Photo {
//
// @Expose public String id;
// @Expose public String name;
// @Expose public String description;
// @Expose @SerializedName("created_at") public String createdAt;
// @Expose public int category;
// @Expose @SerializedName("votes_count") public int votes;
// @Expose public boolean nsfw;
// @Expose @SerializedName("highest_rating") public double highestRating;
// @Expose @SerializedName("times_viewed") public int views;
// @Expose @SerializedName("image_url") public String imageUrl;
// @Expose public String url;
// @Expose public User user;
// @Expose public boolean voted;
// @Expose public boolean favorited;
//
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/views/SquareImageView.java
// public class SquareImageView extends ImageView {
//
// public SquareImageView(Context context) {
// super(context);
// }
//
// public SquareImageView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
// }
// }
| import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.lukekorth.photo_paper.R;
import com.lukekorth.photo_paper.helpers.PicassoHelper;
import com.lukekorth.photo_paper.helpers.Utils;
import com.lukekorth.photo_paper.models.Photo;
import com.lukekorth.photo_paper.views.SquareImageView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import static android.widget.ImageView.ScaleType.CENTER_CROP; | package com.lukekorth.photo_paper.adapters;
public class GridPhotoAdapter extends BaseAdapter {
public static final String TAG = "GridPhotoAdapter";
private Context mContext;
private List<Photo> mPhotos;
private Picasso mPicasso;
private int mOneDpInPx;
public GridPhotoAdapter(Context context, ArrayList<Photo> photos) {
mContext = context;
mPhotos = photos; | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/PicassoHelper.java
// public class PicassoHelper {
//
// public static Picasso getPicasso(Context context) {
// return new Picasso.Builder(context.getApplicationContext())
// .downloader(new OkHttp3Downloader(context.getApplicationContext(), 512000000)) // 512mb
// .indicatorsEnabled(BuildConfig.DEBUG)
// .build();
// }
//
// public static void clearCache(Context context) {
// PicassoTools.clearCache(PicassoHelper.getPicasso(context));
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/Utils.java
// public class Utils {
//
// public static boolean shouldGetPhotos(Context context, Realm realm) {
// return Settings.isEnabled(context) && Utils.needMorePhotos(context, realm) &&
// isCurrentNetworkOk(context);
// }
//
// public static boolean shouldUpdateWallpaper(Context context) {
// return Settings.isEnabled(context) && (((Settings.getLastUpdated(context) +
// (Settings.getUpdateInterval(context) * 1000)) < System.currentTimeMillis()));
// }
//
// public static boolean isCurrentNetworkOk(Context context) {
// return !Settings.useOnlyWifi(context) ||
// (Settings.useOnlyWifi(context) && Utils.isConnectedToWifi(context));
// }
//
// public static boolean needMorePhotos(Context context, Realm realm) {
// return Photos.unseenPhotoCount(context, realm) <= 10;
// }
//
// public static boolean isConnectedToWifi(Context context) {
// ConnectivityManager connectivityManager =
// (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
// return (activeNetwork != null && activeNetwork.isConnectedOrConnecting() &&
// activeNetwork.getType() == ConnectivityManager.TYPE_WIFI);
// }
//
// public static int dpToPx(Context context, double dp) {
// return (int) Math.round(dp * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
// }
//
// public static int getWallpaperHeight(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumHeight();
// }
//
// public static int getWallpaperWidth(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumWidth();
// }
//
// public static int getScreenHeight(Context context) {
// return getScreenResolution(context).y;
// }
//
// public static int getScreenWidth(Context context) {
// return getScreenResolution(context).x;
// }
//
// private static Point getScreenResolution(Context context) {
// WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Point point = new Point();
// windowManager.getDefaultDisplay().getSize(point);
// return point;
// }
//
// public static boolean supportsParallax(Context context) {
// return ((double) getWallpaperWidth(context) / getScreenWidth(context)) >= 2;
// }
//
// public static String getListSummary(Context context, int indexArrayId, int valueArrayId,
// String index, String defaultValue) {
// String[] indexArray = context.getResources().getStringArray(indexArrayId);
// String[] valueArray = context.getResources().getStringArray(valueArrayId);
// int i;
// for (i = 0; i < indexArray.length; i++) {
// if (indexArray[i].equals(index)) {
// return valueArray[i];
// }
// }
// return defaultValue;
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/Photo.java
// public class Photo {
//
// @Expose public String id;
// @Expose public String name;
// @Expose public String description;
// @Expose @SerializedName("created_at") public String createdAt;
// @Expose public int category;
// @Expose @SerializedName("votes_count") public int votes;
// @Expose public boolean nsfw;
// @Expose @SerializedName("highest_rating") public double highestRating;
// @Expose @SerializedName("times_viewed") public int views;
// @Expose @SerializedName("image_url") public String imageUrl;
// @Expose public String url;
// @Expose public User user;
// @Expose public boolean voted;
// @Expose public boolean favorited;
//
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/views/SquareImageView.java
// public class SquareImageView extends ImageView {
//
// public SquareImageView(Context context) {
// super(context);
// }
//
// public SquareImageView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
// }
// }
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/GridPhotoAdapter.java
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.lukekorth.photo_paper.R;
import com.lukekorth.photo_paper.helpers.PicassoHelper;
import com.lukekorth.photo_paper.helpers.Utils;
import com.lukekorth.photo_paper.models.Photo;
import com.lukekorth.photo_paper.views.SquareImageView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import static android.widget.ImageView.ScaleType.CENTER_CROP;
package com.lukekorth.photo_paper.adapters;
public class GridPhotoAdapter extends BaseAdapter {
public static final String TAG = "GridPhotoAdapter";
private Context mContext;
private List<Photo> mPhotos;
private Picasso mPicasso;
private int mOneDpInPx;
public GridPhotoAdapter(Context context, ArrayList<Photo> photos) {
mContext = context;
mPhotos = photos; | mPicasso = PicassoHelper.getPicasso(context); |
lkorth/photo-paper | PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/GridPhotoAdapter.java | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/PicassoHelper.java
// public class PicassoHelper {
//
// public static Picasso getPicasso(Context context) {
// return new Picasso.Builder(context.getApplicationContext())
// .downloader(new OkHttp3Downloader(context.getApplicationContext(), 512000000)) // 512mb
// .indicatorsEnabled(BuildConfig.DEBUG)
// .build();
// }
//
// public static void clearCache(Context context) {
// PicassoTools.clearCache(PicassoHelper.getPicasso(context));
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/Utils.java
// public class Utils {
//
// public static boolean shouldGetPhotos(Context context, Realm realm) {
// return Settings.isEnabled(context) && Utils.needMorePhotos(context, realm) &&
// isCurrentNetworkOk(context);
// }
//
// public static boolean shouldUpdateWallpaper(Context context) {
// return Settings.isEnabled(context) && (((Settings.getLastUpdated(context) +
// (Settings.getUpdateInterval(context) * 1000)) < System.currentTimeMillis()));
// }
//
// public static boolean isCurrentNetworkOk(Context context) {
// return !Settings.useOnlyWifi(context) ||
// (Settings.useOnlyWifi(context) && Utils.isConnectedToWifi(context));
// }
//
// public static boolean needMorePhotos(Context context, Realm realm) {
// return Photos.unseenPhotoCount(context, realm) <= 10;
// }
//
// public static boolean isConnectedToWifi(Context context) {
// ConnectivityManager connectivityManager =
// (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
// return (activeNetwork != null && activeNetwork.isConnectedOrConnecting() &&
// activeNetwork.getType() == ConnectivityManager.TYPE_WIFI);
// }
//
// public static int dpToPx(Context context, double dp) {
// return (int) Math.round(dp * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
// }
//
// public static int getWallpaperHeight(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumHeight();
// }
//
// public static int getWallpaperWidth(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumWidth();
// }
//
// public static int getScreenHeight(Context context) {
// return getScreenResolution(context).y;
// }
//
// public static int getScreenWidth(Context context) {
// return getScreenResolution(context).x;
// }
//
// private static Point getScreenResolution(Context context) {
// WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Point point = new Point();
// windowManager.getDefaultDisplay().getSize(point);
// return point;
// }
//
// public static boolean supportsParallax(Context context) {
// return ((double) getWallpaperWidth(context) / getScreenWidth(context)) >= 2;
// }
//
// public static String getListSummary(Context context, int indexArrayId, int valueArrayId,
// String index, String defaultValue) {
// String[] indexArray = context.getResources().getStringArray(indexArrayId);
// String[] valueArray = context.getResources().getStringArray(valueArrayId);
// int i;
// for (i = 0; i < indexArray.length; i++) {
// if (indexArray[i].equals(index)) {
// return valueArray[i];
// }
// }
// return defaultValue;
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/Photo.java
// public class Photo {
//
// @Expose public String id;
// @Expose public String name;
// @Expose public String description;
// @Expose @SerializedName("created_at") public String createdAt;
// @Expose public int category;
// @Expose @SerializedName("votes_count") public int votes;
// @Expose public boolean nsfw;
// @Expose @SerializedName("highest_rating") public double highestRating;
// @Expose @SerializedName("times_viewed") public int views;
// @Expose @SerializedName("image_url") public String imageUrl;
// @Expose public String url;
// @Expose public User user;
// @Expose public boolean voted;
// @Expose public boolean favorited;
//
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/views/SquareImageView.java
// public class SquareImageView extends ImageView {
//
// public SquareImageView(Context context) {
// super(context);
// }
//
// public SquareImageView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
// }
// }
| import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.lukekorth.photo_paper.R;
import com.lukekorth.photo_paper.helpers.PicassoHelper;
import com.lukekorth.photo_paper.helpers.Utils;
import com.lukekorth.photo_paper.models.Photo;
import com.lukekorth.photo_paper.views.SquareImageView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import static android.widget.ImageView.ScaleType.CENTER_CROP; | package com.lukekorth.photo_paper.adapters;
public class GridPhotoAdapter extends BaseAdapter {
public static final String TAG = "GridPhotoAdapter";
private Context mContext;
private List<Photo> mPhotos;
private Picasso mPicasso;
private int mOneDpInPx;
public GridPhotoAdapter(Context context, ArrayList<Photo> photos) {
mContext = context;
mPhotos = photos;
mPicasso = PicassoHelper.getPicasso(context); | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/PicassoHelper.java
// public class PicassoHelper {
//
// public static Picasso getPicasso(Context context) {
// return new Picasso.Builder(context.getApplicationContext())
// .downloader(new OkHttp3Downloader(context.getApplicationContext(), 512000000)) // 512mb
// .indicatorsEnabled(BuildConfig.DEBUG)
// .build();
// }
//
// public static void clearCache(Context context) {
// PicassoTools.clearCache(PicassoHelper.getPicasso(context));
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/Utils.java
// public class Utils {
//
// public static boolean shouldGetPhotos(Context context, Realm realm) {
// return Settings.isEnabled(context) && Utils.needMorePhotos(context, realm) &&
// isCurrentNetworkOk(context);
// }
//
// public static boolean shouldUpdateWallpaper(Context context) {
// return Settings.isEnabled(context) && (((Settings.getLastUpdated(context) +
// (Settings.getUpdateInterval(context) * 1000)) < System.currentTimeMillis()));
// }
//
// public static boolean isCurrentNetworkOk(Context context) {
// return !Settings.useOnlyWifi(context) ||
// (Settings.useOnlyWifi(context) && Utils.isConnectedToWifi(context));
// }
//
// public static boolean needMorePhotos(Context context, Realm realm) {
// return Photos.unseenPhotoCount(context, realm) <= 10;
// }
//
// public static boolean isConnectedToWifi(Context context) {
// ConnectivityManager connectivityManager =
// (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
// return (activeNetwork != null && activeNetwork.isConnectedOrConnecting() &&
// activeNetwork.getType() == ConnectivityManager.TYPE_WIFI);
// }
//
// public static int dpToPx(Context context, double dp) {
// return (int) Math.round(dp * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
// }
//
// public static int getWallpaperHeight(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumHeight();
// }
//
// public static int getWallpaperWidth(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumWidth();
// }
//
// public static int getScreenHeight(Context context) {
// return getScreenResolution(context).y;
// }
//
// public static int getScreenWidth(Context context) {
// return getScreenResolution(context).x;
// }
//
// private static Point getScreenResolution(Context context) {
// WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Point point = new Point();
// windowManager.getDefaultDisplay().getSize(point);
// return point;
// }
//
// public static boolean supportsParallax(Context context) {
// return ((double) getWallpaperWidth(context) / getScreenWidth(context)) >= 2;
// }
//
// public static String getListSummary(Context context, int indexArrayId, int valueArrayId,
// String index, String defaultValue) {
// String[] indexArray = context.getResources().getStringArray(indexArrayId);
// String[] valueArray = context.getResources().getStringArray(valueArrayId);
// int i;
// for (i = 0; i < indexArray.length; i++) {
// if (indexArray[i].equals(index)) {
// return valueArray[i];
// }
// }
// return defaultValue;
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/Photo.java
// public class Photo {
//
// @Expose public String id;
// @Expose public String name;
// @Expose public String description;
// @Expose @SerializedName("created_at") public String createdAt;
// @Expose public int category;
// @Expose @SerializedName("votes_count") public int votes;
// @Expose public boolean nsfw;
// @Expose @SerializedName("highest_rating") public double highestRating;
// @Expose @SerializedName("times_viewed") public int views;
// @Expose @SerializedName("image_url") public String imageUrl;
// @Expose public String url;
// @Expose public User user;
// @Expose public boolean voted;
// @Expose public boolean favorited;
//
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/views/SquareImageView.java
// public class SquareImageView extends ImageView {
//
// public SquareImageView(Context context) {
// super(context);
// }
//
// public SquareImageView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
// }
// }
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/GridPhotoAdapter.java
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.lukekorth.photo_paper.R;
import com.lukekorth.photo_paper.helpers.PicassoHelper;
import com.lukekorth.photo_paper.helpers.Utils;
import com.lukekorth.photo_paper.models.Photo;
import com.lukekorth.photo_paper.views.SquareImageView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import static android.widget.ImageView.ScaleType.CENTER_CROP;
package com.lukekorth.photo_paper.adapters;
public class GridPhotoAdapter extends BaseAdapter {
public static final String TAG = "GridPhotoAdapter";
private Context mContext;
private List<Photo> mPhotos;
private Picasso mPicasso;
private int mOneDpInPx;
public GridPhotoAdapter(Context context, ArrayList<Photo> photos) {
mContext = context;
mPhotos = photos;
mPicasso = PicassoHelper.getPicasso(context); | mOneDpInPx = Utils.dpToPx(mContext, 0.5); |
lkorth/photo-paper | PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/GridPhotoAdapter.java | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/PicassoHelper.java
// public class PicassoHelper {
//
// public static Picasso getPicasso(Context context) {
// return new Picasso.Builder(context.getApplicationContext())
// .downloader(new OkHttp3Downloader(context.getApplicationContext(), 512000000)) // 512mb
// .indicatorsEnabled(BuildConfig.DEBUG)
// .build();
// }
//
// public static void clearCache(Context context) {
// PicassoTools.clearCache(PicassoHelper.getPicasso(context));
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/Utils.java
// public class Utils {
//
// public static boolean shouldGetPhotos(Context context, Realm realm) {
// return Settings.isEnabled(context) && Utils.needMorePhotos(context, realm) &&
// isCurrentNetworkOk(context);
// }
//
// public static boolean shouldUpdateWallpaper(Context context) {
// return Settings.isEnabled(context) && (((Settings.getLastUpdated(context) +
// (Settings.getUpdateInterval(context) * 1000)) < System.currentTimeMillis()));
// }
//
// public static boolean isCurrentNetworkOk(Context context) {
// return !Settings.useOnlyWifi(context) ||
// (Settings.useOnlyWifi(context) && Utils.isConnectedToWifi(context));
// }
//
// public static boolean needMorePhotos(Context context, Realm realm) {
// return Photos.unseenPhotoCount(context, realm) <= 10;
// }
//
// public static boolean isConnectedToWifi(Context context) {
// ConnectivityManager connectivityManager =
// (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
// return (activeNetwork != null && activeNetwork.isConnectedOrConnecting() &&
// activeNetwork.getType() == ConnectivityManager.TYPE_WIFI);
// }
//
// public static int dpToPx(Context context, double dp) {
// return (int) Math.round(dp * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
// }
//
// public static int getWallpaperHeight(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumHeight();
// }
//
// public static int getWallpaperWidth(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumWidth();
// }
//
// public static int getScreenHeight(Context context) {
// return getScreenResolution(context).y;
// }
//
// public static int getScreenWidth(Context context) {
// return getScreenResolution(context).x;
// }
//
// private static Point getScreenResolution(Context context) {
// WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Point point = new Point();
// windowManager.getDefaultDisplay().getSize(point);
// return point;
// }
//
// public static boolean supportsParallax(Context context) {
// return ((double) getWallpaperWidth(context) / getScreenWidth(context)) >= 2;
// }
//
// public static String getListSummary(Context context, int indexArrayId, int valueArrayId,
// String index, String defaultValue) {
// String[] indexArray = context.getResources().getStringArray(indexArrayId);
// String[] valueArray = context.getResources().getStringArray(valueArrayId);
// int i;
// for (i = 0; i < indexArray.length; i++) {
// if (indexArray[i].equals(index)) {
// return valueArray[i];
// }
// }
// return defaultValue;
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/Photo.java
// public class Photo {
//
// @Expose public String id;
// @Expose public String name;
// @Expose public String description;
// @Expose @SerializedName("created_at") public String createdAt;
// @Expose public int category;
// @Expose @SerializedName("votes_count") public int votes;
// @Expose public boolean nsfw;
// @Expose @SerializedName("highest_rating") public double highestRating;
// @Expose @SerializedName("times_viewed") public int views;
// @Expose @SerializedName("image_url") public String imageUrl;
// @Expose public String url;
// @Expose public User user;
// @Expose public boolean voted;
// @Expose public boolean favorited;
//
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/views/SquareImageView.java
// public class SquareImageView extends ImageView {
//
// public SquareImageView(Context context) {
// super(context);
// }
//
// public SquareImageView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
// }
// }
| import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.lukekorth.photo_paper.R;
import com.lukekorth.photo_paper.helpers.PicassoHelper;
import com.lukekorth.photo_paper.helpers.Utils;
import com.lukekorth.photo_paper.models.Photo;
import com.lukekorth.photo_paper.views.SquareImageView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import static android.widget.ImageView.ScaleType.CENTER_CROP; | mPhotos = photos;
mPicasso = PicassoHelper.getPicasso(context);
mOneDpInPx = Utils.dpToPx(mContext, 0.5);
}
public void setPhotos(List<Photo> photos) {
mPhotos = photos;
}
public List<Photo> getPhotos() {
return mPhotos;
}
@Override
public int getCount() {
return mPhotos.size();
}
@Override
public Photo getItem(int position) {
return mPhotos.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) { | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/PicassoHelper.java
// public class PicassoHelper {
//
// public static Picasso getPicasso(Context context) {
// return new Picasso.Builder(context.getApplicationContext())
// .downloader(new OkHttp3Downloader(context.getApplicationContext(), 512000000)) // 512mb
// .indicatorsEnabled(BuildConfig.DEBUG)
// .build();
// }
//
// public static void clearCache(Context context) {
// PicassoTools.clearCache(PicassoHelper.getPicasso(context));
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/Utils.java
// public class Utils {
//
// public static boolean shouldGetPhotos(Context context, Realm realm) {
// return Settings.isEnabled(context) && Utils.needMorePhotos(context, realm) &&
// isCurrentNetworkOk(context);
// }
//
// public static boolean shouldUpdateWallpaper(Context context) {
// return Settings.isEnabled(context) && (((Settings.getLastUpdated(context) +
// (Settings.getUpdateInterval(context) * 1000)) < System.currentTimeMillis()));
// }
//
// public static boolean isCurrentNetworkOk(Context context) {
// return !Settings.useOnlyWifi(context) ||
// (Settings.useOnlyWifi(context) && Utils.isConnectedToWifi(context));
// }
//
// public static boolean needMorePhotos(Context context, Realm realm) {
// return Photos.unseenPhotoCount(context, realm) <= 10;
// }
//
// public static boolean isConnectedToWifi(Context context) {
// ConnectivityManager connectivityManager =
// (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
// return (activeNetwork != null && activeNetwork.isConnectedOrConnecting() &&
// activeNetwork.getType() == ConnectivityManager.TYPE_WIFI);
// }
//
// public static int dpToPx(Context context, double dp) {
// return (int) Math.round(dp * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
// }
//
// public static int getWallpaperHeight(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumHeight();
// }
//
// public static int getWallpaperWidth(Context context) {
// return WallpaperManager.getInstance(context).getDesiredMinimumWidth();
// }
//
// public static int getScreenHeight(Context context) {
// return getScreenResolution(context).y;
// }
//
// public static int getScreenWidth(Context context) {
// return getScreenResolution(context).x;
// }
//
// private static Point getScreenResolution(Context context) {
// WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// Point point = new Point();
// windowManager.getDefaultDisplay().getSize(point);
// return point;
// }
//
// public static boolean supportsParallax(Context context) {
// return ((double) getWallpaperWidth(context) / getScreenWidth(context)) >= 2;
// }
//
// public static String getListSummary(Context context, int indexArrayId, int valueArrayId,
// String index, String defaultValue) {
// String[] indexArray = context.getResources().getStringArray(indexArrayId);
// String[] valueArray = context.getResources().getStringArray(valueArrayId);
// int i;
// for (i = 0; i < indexArray.length; i++) {
// if (indexArray[i].equals(index)) {
// return valueArray[i];
// }
// }
// return defaultValue;
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/Photo.java
// public class Photo {
//
// @Expose public String id;
// @Expose public String name;
// @Expose public String description;
// @Expose @SerializedName("created_at") public String createdAt;
// @Expose public int category;
// @Expose @SerializedName("votes_count") public int votes;
// @Expose public boolean nsfw;
// @Expose @SerializedName("highest_rating") public double highestRating;
// @Expose @SerializedName("times_viewed") public int views;
// @Expose @SerializedName("image_url") public String imageUrl;
// @Expose public String url;
// @Expose public User user;
// @Expose public boolean voted;
// @Expose public boolean favorited;
//
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/views/SquareImageView.java
// public class SquareImageView extends ImageView {
//
// public SquareImageView(Context context) {
// super(context);
// }
//
// public SquareImageView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
// }
// }
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/adapters/GridPhotoAdapter.java
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.lukekorth.photo_paper.R;
import com.lukekorth.photo_paper.helpers.PicassoHelper;
import com.lukekorth.photo_paper.helpers.Utils;
import com.lukekorth.photo_paper.models.Photo;
import com.lukekorth.photo_paper.views.SquareImageView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import static android.widget.ImageView.ScaleType.CENTER_CROP;
mPhotos = photos;
mPicasso = PicassoHelper.getPicasso(context);
mOneDpInPx = Utils.dpToPx(mContext, 0.5);
}
public void setPhotos(List<Photo> photos) {
mPhotos = photos;
}
public List<Photo> getPhotos() {
return mPhotos;
}
@Override
public int getCount() {
return mPhotos.size();
}
@Override
public Photo getItem(int position) {
return mPhotos.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) { | SquareImageView view = (SquareImageView) convertView; |
lkorth/photo-paper | PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/AlarmHelper.java | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/services/WallpaperService.java
// public class WallpaperService extends IntentService {
//
// public WallpaperService() {
// super("WallpaperService");
// }
//
// @Override
// protected void onHandleIntent(Intent intent) {
// Logger logger = LoggerFactory.getLogger("WallpaperService");
//
// if (!Settings.isEnabled(this)) {
// logger.debug("App is not enabled");
// return;
// }
//
// PowerManager.WakeLock wakeLock = ((PowerManager) getSystemService(POWER_SERVICE))
// .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "500pxApiService");
// wakeLock.acquire(TimeUnit.MINUTES.toMillis(1));
//
// WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
// int width = wallpaperManager.getDesiredMinimumWidth();
// int height = wallpaperManager.getDesiredMinimumHeight();
// if (Utils.supportsParallax(this) && !Settings.useParallax(this)) {
// width = width / 2;
// }
//
// Realm realm = Realm.getDefaultInstance();
// Photos photo = Photos.getNextPhoto(this, realm);
// if (photo != null) {
// try {
// logger.debug("Setting wallpaper to " + width + "px wide by " + height + "px tall");
//
// RequestCreator request = PicassoHelper.getPicasso(this)
// .load(photo.imageUrl)
// .centerCrop()
// .resize(width, height);
//
// if (Settings.useOnlyWifi(this) && !Utils.isConnectedToWifi(this)) {
// request.networkPolicy(NetworkPolicy.OFFLINE);
// }
//
// Bitmap bitmap = request.get();
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// wallpaperManager.setBitmap(bitmap, null, false, WallpaperManager.FLAG_SYSTEM);
// wallpaperManager.setBitmap(bitmap, null, false, WallpaperManager.FLAG_LOCK);
// } else {
// wallpaperManager.setBitmap(bitmap);
// }
//
// realm.beginTransaction();
// photo.setPalette(Palette.generate(bitmap).getMutedColor(getResources().getColor(R.color.brown)));
// photo.setSeen(true);
// photo.setSeenAt(System.currentTimeMillis());
// realm.commitTransaction();
//
// Settings.setUpdated(this);
//
// FirebaseAnalytics.getInstance(this).logEvent("wallpaper_updated", null);
// } catch (IOException e) {
// logger.error(e.toString());
// for (StackTraceElement trace : e.getStackTrace()) {
// logger.error(trace.toString());
// }
//
// if (e.getCause() != null) {
// logger.error(e.getCause().toString());
// for (StackTraceElement trace : e.getCause().getStackTrace()) {
// logger.error(trace.toString());
// }
// }
//
// realm.beginTransaction();
// if (photo.getFailedCount() > 10) {
// photo.deleteFromRealm();
// } else {
// photo.setFailedCount(photo.getFailedCount() + 1);
// }
// realm.commitTransaction();
//
// startService(new Intent(this, WallpaperService.class));
// }
// } else {
// logger.debug("Next photo was null");
// }
//
// if (Utils.needMorePhotos(this, realm)) {
// logger.debug("Getting more photos via PhotoDownloadIntentService");
// PhotoDownloadIntentService.downloadPhotos(this);
// }
//
// WallpaperApplication.getBus().post(new WallpaperChangedEvent());
//
// realm.close();
// wakeLock.release();
// }
// }
| import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
import com.lukekorth.photo_paper.services.WallpaperService; | package com.lukekorth.photo_paper.helpers;
public class AlarmHelper {
public static boolean isAlarmSet(Context context) {
return (PendingIntent.getService(context, 0, | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/services/WallpaperService.java
// public class WallpaperService extends IntentService {
//
// public WallpaperService() {
// super("WallpaperService");
// }
//
// @Override
// protected void onHandleIntent(Intent intent) {
// Logger logger = LoggerFactory.getLogger("WallpaperService");
//
// if (!Settings.isEnabled(this)) {
// logger.debug("App is not enabled");
// return;
// }
//
// PowerManager.WakeLock wakeLock = ((PowerManager) getSystemService(POWER_SERVICE))
// .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "500pxApiService");
// wakeLock.acquire(TimeUnit.MINUTES.toMillis(1));
//
// WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
// int width = wallpaperManager.getDesiredMinimumWidth();
// int height = wallpaperManager.getDesiredMinimumHeight();
// if (Utils.supportsParallax(this) && !Settings.useParallax(this)) {
// width = width / 2;
// }
//
// Realm realm = Realm.getDefaultInstance();
// Photos photo = Photos.getNextPhoto(this, realm);
// if (photo != null) {
// try {
// logger.debug("Setting wallpaper to " + width + "px wide by " + height + "px tall");
//
// RequestCreator request = PicassoHelper.getPicasso(this)
// .load(photo.imageUrl)
// .centerCrop()
// .resize(width, height);
//
// if (Settings.useOnlyWifi(this) && !Utils.isConnectedToWifi(this)) {
// request.networkPolicy(NetworkPolicy.OFFLINE);
// }
//
// Bitmap bitmap = request.get();
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// wallpaperManager.setBitmap(bitmap, null, false, WallpaperManager.FLAG_SYSTEM);
// wallpaperManager.setBitmap(bitmap, null, false, WallpaperManager.FLAG_LOCK);
// } else {
// wallpaperManager.setBitmap(bitmap);
// }
//
// realm.beginTransaction();
// photo.setPalette(Palette.generate(bitmap).getMutedColor(getResources().getColor(R.color.brown)));
// photo.setSeen(true);
// photo.setSeenAt(System.currentTimeMillis());
// realm.commitTransaction();
//
// Settings.setUpdated(this);
//
// FirebaseAnalytics.getInstance(this).logEvent("wallpaper_updated", null);
// } catch (IOException e) {
// logger.error(e.toString());
// for (StackTraceElement trace : e.getStackTrace()) {
// logger.error(trace.toString());
// }
//
// if (e.getCause() != null) {
// logger.error(e.getCause().toString());
// for (StackTraceElement trace : e.getCause().getStackTrace()) {
// logger.error(trace.toString());
// }
// }
//
// realm.beginTransaction();
// if (photo.getFailedCount() > 10) {
// photo.deleteFromRealm();
// } else {
// photo.setFailedCount(photo.getFailedCount() + 1);
// }
// realm.commitTransaction();
//
// startService(new Intent(this, WallpaperService.class));
// }
// } else {
// logger.debug("Next photo was null");
// }
//
// if (Utils.needMorePhotos(this, realm)) {
// logger.debug("Getting more photos via PhotoDownloadIntentService");
// PhotoDownloadIntentService.downloadPhotos(this);
// }
//
// WallpaperApplication.getBus().post(new WallpaperChangedEvent());
//
// realm.close();
// wakeLock.release();
// }
// }
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/helpers/AlarmHelper.java
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
import com.lukekorth.photo_paper.services.WallpaperService;
package com.lukekorth.photo_paper.helpers;
public class AlarmHelper {
public static boolean isAlarmSet(Context context) {
return (PendingIntent.getService(context, 0, | new Intent(context, WallpaperService.class), PendingIntent.FLAG_NO_CREATE)) != null; |
lkorth/photo-paper | PhotoPaper/src/main/java/com/lukekorth/photo_paper/api/FiveHundredPxClient.java | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/ApiResponse.java
// public class ApiResponse {
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/GalleryResponse.java
// public class GalleryResponse {
//
// @Expose public List<Gallery> galleries;
//
// public class Gallery {
//
// @Expose public String id;
// @Expose public String name;
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/PhotoGalleryRequest.java
// public class PhotoGalleryRequest {
//
// @Expose private Add add;
// @Expose private Remove remove;
//
// public static PhotoGalleryRequest add(String photoId) {
// PhotoGalleryRequest photoGalleryRequest = new PhotoGalleryRequest();
// photoGalleryRequest.add = new Add(photoId);
// return photoGalleryRequest;
// }
//
// public static PhotoGalleryRequest remove(String photoId) {
// PhotoGalleryRequest photoGalleryRequest = new PhotoGalleryRequest();
// photoGalleryRequest.remove = new Remove(photoId);
// return photoGalleryRequest;
// }
//
// private static class Add {
//
// @Expose private List<String> photos;
//
// private Add(String photoId) {
// photos = Collections.singletonList(photoId);
// }
// }
//
// private static class Remove {
//
// @Expose private List<String> photos;
//
// private Remove(String photoId) {
// photos = Collections.singletonList(photoId);
// }
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/PhotoResponse.java
// public class PhotoResponse {
//
// @Expose public Photo photo;
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/PhotosResponse.java
// public class PhotosResponse {
//
// @Expose public String feature;
// @Expose @SerializedName("current_page") public int currentPage;
// @Expose @SerializedName("total_pages") public int totalPages;
// @Expose public Photo[] photos;
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/SearchResult.java
// public class SearchResult {
//
// @Expose public List<Photo> photos;
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/UsersResponse.java
// public class UsersResponse {
//
// @Expose public User user;
// }
| import com.lukekorth.photo_paper.models.ApiResponse;
import com.lukekorth.photo_paper.models.GalleryResponse;
import com.lukekorth.photo_paper.models.PhotoGalleryRequest;
import com.lukekorth.photo_paper.models.PhotoResponse;
import com.lukekorth.photo_paper.models.PhotosResponse;
import com.lukekorth.photo_paper.models.SearchResult;
import com.lukekorth.photo_paper.models.UsersResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query; | package com.lukekorth.photo_paper.api;
public interface FiveHundredPxClient {
@GET("users") | // Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/ApiResponse.java
// public class ApiResponse {
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/GalleryResponse.java
// public class GalleryResponse {
//
// @Expose public List<Gallery> galleries;
//
// public class Gallery {
//
// @Expose public String id;
// @Expose public String name;
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/PhotoGalleryRequest.java
// public class PhotoGalleryRequest {
//
// @Expose private Add add;
// @Expose private Remove remove;
//
// public static PhotoGalleryRequest add(String photoId) {
// PhotoGalleryRequest photoGalleryRequest = new PhotoGalleryRequest();
// photoGalleryRequest.add = new Add(photoId);
// return photoGalleryRequest;
// }
//
// public static PhotoGalleryRequest remove(String photoId) {
// PhotoGalleryRequest photoGalleryRequest = new PhotoGalleryRequest();
// photoGalleryRequest.remove = new Remove(photoId);
// return photoGalleryRequest;
// }
//
// private static class Add {
//
// @Expose private List<String> photos;
//
// private Add(String photoId) {
// photos = Collections.singletonList(photoId);
// }
// }
//
// private static class Remove {
//
// @Expose private List<String> photos;
//
// private Remove(String photoId) {
// photos = Collections.singletonList(photoId);
// }
// }
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/PhotoResponse.java
// public class PhotoResponse {
//
// @Expose public Photo photo;
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/PhotosResponse.java
// public class PhotosResponse {
//
// @Expose public String feature;
// @Expose @SerializedName("current_page") public int currentPage;
// @Expose @SerializedName("total_pages") public int totalPages;
// @Expose public Photo[] photos;
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/SearchResult.java
// public class SearchResult {
//
// @Expose public List<Photo> photos;
// }
//
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/models/UsersResponse.java
// public class UsersResponse {
//
// @Expose public User user;
// }
// Path: PhotoPaper/src/main/java/com/lukekorth/photo_paper/api/FiveHundredPxClient.java
import com.lukekorth.photo_paper.models.ApiResponse;
import com.lukekorth.photo_paper.models.GalleryResponse;
import com.lukekorth.photo_paper.models.PhotoGalleryRequest;
import com.lukekorth.photo_paper.models.PhotoResponse;
import com.lukekorth.photo_paper.models.PhotosResponse;
import com.lukekorth.photo_paper.models.SearchResult;
import com.lukekorth.photo_paper.models.UsersResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
package com.lukekorth.photo_paper.api;
public interface FiveHundredPxClient {
@GET("users") | Call<UsersResponse> users(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.