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
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/BuiltinModConfigurator.java
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java // public class SimpleEventConfig implements IEventConfig { // private final ImmutableList<Listener<?>> listeners; // // private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { // this.listeners = listeners; // } // // public static Builder builder() { // return new Builder(); // } // // @Override // public void applyTo(EventMap.Builder builder) { // for (Listener<?> listener : listeners) { // putListener(builder, listener); // } // } // // private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { // builder.put(listener.target, listener.listener); // } // // public static class Builder { // private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); // // private Builder() { // } // // public <E extends IEvent> Builder listen(IEventTarget<E> target, IEventListener<E> listener) { // listeners.add(new Listener<>(target, listener)); // return this; // } // // public SimpleEventConfig build() { // return new SimpleEventConfig(listeners.build()); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // } // } // // Path: src/main/java/com/openmodloader/core/event/GuiEvent.java // public abstract class GuiEvent<T extends GuiScreen> implements IEvent { // protected final T gui; // // public GuiEvent(T gui) { // this.gui = gui; // } // // public T getGui() { // return gui; // } // // public static class Open<T extends GuiScreen> extends GuiEvent<T> { // public Open(T gui) { // super(gui); // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target(Class<T> target) { // return GenericEventTarget.of(Open.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target() { // return GenericEventTarget.of(Open.class, GuiScreen.class); // } // } // // public static class Draw<T extends GuiScreen> extends GuiEvent<T> { // protected final TextRenderer textRenderer; // // public Draw(T gui, TextRenderer textRenderer) { // super(gui); // this.textRenderer = textRenderer; // } // // public TextRenderer getTextRenderer() { // return textRenderer; // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target(Class<T> target) { // return GenericEventTarget.of(Draw.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target() { // return GenericEventTarget.of(Draw.class, GuiScreen.class); // } // } // }
import com.openmodloader.api.event.EventContext; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.api.mod.config.SimpleEventConfig; import com.openmodloader.core.event.GuiEvent; import net.minecraft.client.gui.menu.GuiMainMenu; import net.minecraft.client.render.text.TextRenderer;
package com.openmodloader.loader; public class BuiltinModConfigurator implements IModConfigurator { @Override
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java // public class SimpleEventConfig implements IEventConfig { // private final ImmutableList<Listener<?>> listeners; // // private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { // this.listeners = listeners; // } // // public static Builder builder() { // return new Builder(); // } // // @Override // public void applyTo(EventMap.Builder builder) { // for (Listener<?> listener : listeners) { // putListener(builder, listener); // } // } // // private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { // builder.put(listener.target, listener.listener); // } // // public static class Builder { // private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); // // private Builder() { // } // // public <E extends IEvent> Builder listen(IEventTarget<E> target, IEventListener<E> listener) { // listeners.add(new Listener<>(target, listener)); // return this; // } // // public SimpleEventConfig build() { // return new SimpleEventConfig(listeners.build()); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // } // } // // Path: src/main/java/com/openmodloader/core/event/GuiEvent.java // public abstract class GuiEvent<T extends GuiScreen> implements IEvent { // protected final T gui; // // public GuiEvent(T gui) { // this.gui = gui; // } // // public T getGui() { // return gui; // } // // public static class Open<T extends GuiScreen> extends GuiEvent<T> { // public Open(T gui) { // super(gui); // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target(Class<T> target) { // return GenericEventTarget.of(Open.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target() { // return GenericEventTarget.of(Open.class, GuiScreen.class); // } // } // // public static class Draw<T extends GuiScreen> extends GuiEvent<T> { // protected final TextRenderer textRenderer; // // public Draw(T gui, TextRenderer textRenderer) { // super(gui); // this.textRenderer = textRenderer; // } // // public TextRenderer getTextRenderer() { // return textRenderer; // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target(Class<T> target) { // return GenericEventTarget.of(Draw.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target() { // return GenericEventTarget.of(Draw.class, GuiScreen.class); // } // } // } // Path: src/main/java/com/openmodloader/loader/BuiltinModConfigurator.java import com.openmodloader.api.event.EventContext; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.api.mod.config.SimpleEventConfig; import com.openmodloader.core.event.GuiEvent; import net.minecraft.client.gui.menu.GuiMainMenu; import net.minecraft.client.render.text.TextRenderer; package com.openmodloader.loader; public class BuiltinModConfigurator implements IModConfigurator { @Override
public void configure(IModConfig config) {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/BuiltinModConfigurator.java
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java // public class SimpleEventConfig implements IEventConfig { // private final ImmutableList<Listener<?>> listeners; // // private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { // this.listeners = listeners; // } // // public static Builder builder() { // return new Builder(); // } // // @Override // public void applyTo(EventMap.Builder builder) { // for (Listener<?> listener : listeners) { // putListener(builder, listener); // } // } // // private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { // builder.put(listener.target, listener.listener); // } // // public static class Builder { // private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); // // private Builder() { // } // // public <E extends IEvent> Builder listen(IEventTarget<E> target, IEventListener<E> listener) { // listeners.add(new Listener<>(target, listener)); // return this; // } // // public SimpleEventConfig build() { // return new SimpleEventConfig(listeners.build()); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // } // } // // Path: src/main/java/com/openmodloader/core/event/GuiEvent.java // public abstract class GuiEvent<T extends GuiScreen> implements IEvent { // protected final T gui; // // public GuiEvent(T gui) { // this.gui = gui; // } // // public T getGui() { // return gui; // } // // public static class Open<T extends GuiScreen> extends GuiEvent<T> { // public Open(T gui) { // super(gui); // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target(Class<T> target) { // return GenericEventTarget.of(Open.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target() { // return GenericEventTarget.of(Open.class, GuiScreen.class); // } // } // // public static class Draw<T extends GuiScreen> extends GuiEvent<T> { // protected final TextRenderer textRenderer; // // public Draw(T gui, TextRenderer textRenderer) { // super(gui); // this.textRenderer = textRenderer; // } // // public TextRenderer getTextRenderer() { // return textRenderer; // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target(Class<T> target) { // return GenericEventTarget.of(Draw.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target() { // return GenericEventTarget.of(Draw.class, GuiScreen.class); // } // } // }
import com.openmodloader.api.event.EventContext; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.api.mod.config.SimpleEventConfig; import com.openmodloader.core.event.GuiEvent; import net.minecraft.client.gui.menu.GuiMainMenu; import net.minecraft.client.render.text.TextRenderer;
package com.openmodloader.loader; public class BuiltinModConfigurator implements IModConfigurator { @Override public void configure(IModConfig config) {
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java // public class SimpleEventConfig implements IEventConfig { // private final ImmutableList<Listener<?>> listeners; // // private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { // this.listeners = listeners; // } // // public static Builder builder() { // return new Builder(); // } // // @Override // public void applyTo(EventMap.Builder builder) { // for (Listener<?> listener : listeners) { // putListener(builder, listener); // } // } // // private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { // builder.put(listener.target, listener.listener); // } // // public static class Builder { // private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); // // private Builder() { // } // // public <E extends IEvent> Builder listen(IEventTarget<E> target, IEventListener<E> listener) { // listeners.add(new Listener<>(target, listener)); // return this; // } // // public SimpleEventConfig build() { // return new SimpleEventConfig(listeners.build()); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // } // } // // Path: src/main/java/com/openmodloader/core/event/GuiEvent.java // public abstract class GuiEvent<T extends GuiScreen> implements IEvent { // protected final T gui; // // public GuiEvent(T gui) { // this.gui = gui; // } // // public T getGui() { // return gui; // } // // public static class Open<T extends GuiScreen> extends GuiEvent<T> { // public Open(T gui) { // super(gui); // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target(Class<T> target) { // return GenericEventTarget.of(Open.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target() { // return GenericEventTarget.of(Open.class, GuiScreen.class); // } // } // // public static class Draw<T extends GuiScreen> extends GuiEvent<T> { // protected final TextRenderer textRenderer; // // public Draw(T gui, TextRenderer textRenderer) { // super(gui); // this.textRenderer = textRenderer; // } // // public TextRenderer getTextRenderer() { // return textRenderer; // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target(Class<T> target) { // return GenericEventTarget.of(Draw.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target() { // return GenericEventTarget.of(Draw.class, GuiScreen.class); // } // } // } // Path: src/main/java/com/openmodloader/loader/BuiltinModConfigurator.java import com.openmodloader.api.event.EventContext; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.api.mod.config.SimpleEventConfig; import com.openmodloader.core.event.GuiEvent; import net.minecraft.client.gui.menu.GuiMainMenu; import net.minecraft.client.render.text.TextRenderer; package com.openmodloader.loader; public class BuiltinModConfigurator implements IModConfigurator { @Override public void configure(IModConfig config) {
config.addEventConfig(SimpleEventConfig.builder()
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/BuiltinModConfigurator.java
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java // public class SimpleEventConfig implements IEventConfig { // private final ImmutableList<Listener<?>> listeners; // // private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { // this.listeners = listeners; // } // // public static Builder builder() { // return new Builder(); // } // // @Override // public void applyTo(EventMap.Builder builder) { // for (Listener<?> listener : listeners) { // putListener(builder, listener); // } // } // // private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { // builder.put(listener.target, listener.listener); // } // // public static class Builder { // private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); // // private Builder() { // } // // public <E extends IEvent> Builder listen(IEventTarget<E> target, IEventListener<E> listener) { // listeners.add(new Listener<>(target, listener)); // return this; // } // // public SimpleEventConfig build() { // return new SimpleEventConfig(listeners.build()); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // } // } // // Path: src/main/java/com/openmodloader/core/event/GuiEvent.java // public abstract class GuiEvent<T extends GuiScreen> implements IEvent { // protected final T gui; // // public GuiEvent(T gui) { // this.gui = gui; // } // // public T getGui() { // return gui; // } // // public static class Open<T extends GuiScreen> extends GuiEvent<T> { // public Open(T gui) { // super(gui); // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target(Class<T> target) { // return GenericEventTarget.of(Open.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target() { // return GenericEventTarget.of(Open.class, GuiScreen.class); // } // } // // public static class Draw<T extends GuiScreen> extends GuiEvent<T> { // protected final TextRenderer textRenderer; // // public Draw(T gui, TextRenderer textRenderer) { // super(gui); // this.textRenderer = textRenderer; // } // // public TextRenderer getTextRenderer() { // return textRenderer; // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target(Class<T> target) { // return GenericEventTarget.of(Draw.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target() { // return GenericEventTarget.of(Draw.class, GuiScreen.class); // } // } // }
import com.openmodloader.api.event.EventContext; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.api.mod.config.SimpleEventConfig; import com.openmodloader.core.event.GuiEvent; import net.minecraft.client.gui.menu.GuiMainMenu; import net.minecraft.client.render.text.TextRenderer;
package com.openmodloader.loader; public class BuiltinModConfigurator implements IModConfigurator { @Override public void configure(IModConfig config) { config.addEventConfig(SimpleEventConfig.builder()
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java // public class SimpleEventConfig implements IEventConfig { // private final ImmutableList<Listener<?>> listeners; // // private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { // this.listeners = listeners; // } // // public static Builder builder() { // return new Builder(); // } // // @Override // public void applyTo(EventMap.Builder builder) { // for (Listener<?> listener : listeners) { // putListener(builder, listener); // } // } // // private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { // builder.put(listener.target, listener.listener); // } // // public static class Builder { // private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); // // private Builder() { // } // // public <E extends IEvent> Builder listen(IEventTarget<E> target, IEventListener<E> listener) { // listeners.add(new Listener<>(target, listener)); // return this; // } // // public SimpleEventConfig build() { // return new SimpleEventConfig(listeners.build()); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // } // } // // Path: src/main/java/com/openmodloader/core/event/GuiEvent.java // public abstract class GuiEvent<T extends GuiScreen> implements IEvent { // protected final T gui; // // public GuiEvent(T gui) { // this.gui = gui; // } // // public T getGui() { // return gui; // } // // public static class Open<T extends GuiScreen> extends GuiEvent<T> { // public Open(T gui) { // super(gui); // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target(Class<T> target) { // return GenericEventTarget.of(Open.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target() { // return GenericEventTarget.of(Open.class, GuiScreen.class); // } // } // // public static class Draw<T extends GuiScreen> extends GuiEvent<T> { // protected final TextRenderer textRenderer; // // public Draw(T gui, TextRenderer textRenderer) { // super(gui); // this.textRenderer = textRenderer; // } // // public TextRenderer getTextRenderer() { // return textRenderer; // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target(Class<T> target) { // return GenericEventTarget.of(Draw.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target() { // return GenericEventTarget.of(Draw.class, GuiScreen.class); // } // } // } // Path: src/main/java/com/openmodloader/loader/BuiltinModConfigurator.java import com.openmodloader.api.event.EventContext; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.api.mod.config.SimpleEventConfig; import com.openmodloader.core.event.GuiEvent; import net.minecraft.client.gui.menu.GuiMainMenu; import net.minecraft.client.render.text.TextRenderer; package com.openmodloader.loader; public class BuiltinModConfigurator implements IModConfigurator { @Override public void configure(IModConfig config) { config.addEventConfig(SimpleEventConfig.builder()
.listen(GuiEvent.Draw.target(GuiMainMenu.class), this::renderMainMenu)
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/BuiltinModConfigurator.java
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java // public class SimpleEventConfig implements IEventConfig { // private final ImmutableList<Listener<?>> listeners; // // private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { // this.listeners = listeners; // } // // public static Builder builder() { // return new Builder(); // } // // @Override // public void applyTo(EventMap.Builder builder) { // for (Listener<?> listener : listeners) { // putListener(builder, listener); // } // } // // private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { // builder.put(listener.target, listener.listener); // } // // public static class Builder { // private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); // // private Builder() { // } // // public <E extends IEvent> Builder listen(IEventTarget<E> target, IEventListener<E> listener) { // listeners.add(new Listener<>(target, listener)); // return this; // } // // public SimpleEventConfig build() { // return new SimpleEventConfig(listeners.build()); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // } // } // // Path: src/main/java/com/openmodloader/core/event/GuiEvent.java // public abstract class GuiEvent<T extends GuiScreen> implements IEvent { // protected final T gui; // // public GuiEvent(T gui) { // this.gui = gui; // } // // public T getGui() { // return gui; // } // // public static class Open<T extends GuiScreen> extends GuiEvent<T> { // public Open(T gui) { // super(gui); // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target(Class<T> target) { // return GenericEventTarget.of(Open.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target() { // return GenericEventTarget.of(Open.class, GuiScreen.class); // } // } // // public static class Draw<T extends GuiScreen> extends GuiEvent<T> { // protected final TextRenderer textRenderer; // // public Draw(T gui, TextRenderer textRenderer) { // super(gui); // this.textRenderer = textRenderer; // } // // public TextRenderer getTextRenderer() { // return textRenderer; // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target(Class<T> target) { // return GenericEventTarget.of(Draw.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target() { // return GenericEventTarget.of(Draw.class, GuiScreen.class); // } // } // }
import com.openmodloader.api.event.EventContext; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.api.mod.config.SimpleEventConfig; import com.openmodloader.core.event.GuiEvent; import net.minecraft.client.gui.menu.GuiMainMenu; import net.minecraft.client.render.text.TextRenderer;
package com.openmodloader.loader; public class BuiltinModConfigurator implements IModConfigurator { @Override public void configure(IModConfig config) { config.addEventConfig(SimpleEventConfig.builder() .listen(GuiEvent.Draw.target(GuiMainMenu.class), this::renderMainMenu) .build() ); }
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java // public class SimpleEventConfig implements IEventConfig { // private final ImmutableList<Listener<?>> listeners; // // private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { // this.listeners = listeners; // } // // public static Builder builder() { // return new Builder(); // } // // @Override // public void applyTo(EventMap.Builder builder) { // for (Listener<?> listener : listeners) { // putListener(builder, listener); // } // } // // private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { // builder.put(listener.target, listener.listener); // } // // public static class Builder { // private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); // // private Builder() { // } // // public <E extends IEvent> Builder listen(IEventTarget<E> target, IEventListener<E> listener) { // listeners.add(new Listener<>(target, listener)); // return this; // } // // public SimpleEventConfig build() { // return new SimpleEventConfig(listeners.build()); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // } // } // // Path: src/main/java/com/openmodloader/core/event/GuiEvent.java // public abstract class GuiEvent<T extends GuiScreen> implements IEvent { // protected final T gui; // // public GuiEvent(T gui) { // this.gui = gui; // } // // public T getGui() { // return gui; // } // // public static class Open<T extends GuiScreen> extends GuiEvent<T> { // public Open(T gui) { // super(gui); // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target(Class<T> target) { // return GenericEventTarget.of(Open.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Open<T>> target() { // return GenericEventTarget.of(Open.class, GuiScreen.class); // } // } // // public static class Draw<T extends GuiScreen> extends GuiEvent<T> { // protected final TextRenderer textRenderer; // // public Draw(T gui, TextRenderer textRenderer) { // super(gui); // this.textRenderer = textRenderer; // } // // public TextRenderer getTextRenderer() { // return textRenderer; // } // // @Override // public IEventTarget<?> makeTarget() { // return target(gui.getClass()); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target(Class<T> target) { // return GenericEventTarget.of(Draw.class, target); // } // // public static <T extends GuiScreen> IEventTarget<Draw<T>> target() { // return GenericEventTarget.of(Draw.class, GuiScreen.class); // } // } // } // Path: src/main/java/com/openmodloader/loader/BuiltinModConfigurator.java import com.openmodloader.api.event.EventContext; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.api.mod.config.SimpleEventConfig; import com.openmodloader.core.event.GuiEvent; import net.minecraft.client.gui.menu.GuiMainMenu; import net.minecraft.client.render.text.TextRenderer; package com.openmodloader.loader; public class BuiltinModConfigurator implements IModConfigurator { @Override public void configure(IModConfig config) { config.addEventConfig(SimpleEventConfig.builder() .listen(GuiEvent.Draw.target(GuiMainMenu.class), this::renderMainMenu) .build() ); }
private void renderMainMenu(GuiEvent.Draw<GuiMainMenu> event, EventContext context) {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/api/mod/config/SidedModConfigurator.java
// Path: src/main/java/com/openmodloader/api/NestedSupplier.java // @FunctionalInterface // public interface NestedSupplier<T> { // Supplier<T> inner(); // // default T get() { // return this.inner().get(); // } // } // // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java // public final class OpenModLoader { // public static final Version VERSION = Version.valueOf("1.0.0"); // // private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); // // private final ImmutableList<IModReporter> modReporters; // private final ImmutableMap<String, ILanguageAdapter> languageAdapters; // // private static OpenModLoader instance; // private static IGameContext context; // // private IEventDispatcher eventDispatcher = VoidEventDispatcher.INSTANCE; // // private ModContext installedModContext; // private ModContext modContext; // // OpenModLoader(ImmutableList<IModReporter> modReporters, ImmutableMap<String, ILanguageAdapter> languageAdapters) { // this.modReporters = modReporters; // this.languageAdapters = languageAdapters; // } // // public static void offerContext(IGameContext context) { // if (OpenModLoader.context != null) { // throw new IllegalStateException("OmlContext has already been initialized"); // } // OpenModLoader.context = context; // } // // public static void offerInstance(OpenModLoader instance) { // if (OpenModLoader.instance != null) { // throw new IllegalStateException("OpenModLoader has already been initialized!"); // } // OpenModLoader.instance = instance; // } // // public static OpenModLoader get() { // if (instance == null) { // throw new IllegalStateException("OpenModLoader not yet initialized!"); // } // return instance; // } // // public static IGameContext getContext() { // return context; // } // // public IEventDispatcher getEventDispatcher() { // return eventDispatcher; // } // // @Nullable // public ModContext getInstalledModContext() { // return installedModContext; // } // // @Nullable // public ModContext getModContext() { // return modContext; // } // // public void initialize() { // offerInstance(this); // // Collection<ModCandidate> installedCandidates = collectModCandidates(); // LOGGER.info("Collected {} mod candidates", installedCandidates.size()); // // List<Mod> installedMods = installedCandidates.stream() // .map(ModCandidate::construct) // .collect(Collectors.toList()); // // List<Mod> globalMods = installedMods.stream() // .filter(Mod::isGlobal) // .collect(Collectors.toList()); // // installedModContext = new ModContext(installedMods); // modContext = new ModContext(globalMods); // // eventDispatcher = modContext.buildEventDispatcher(); // // for (Registry<?> registry : Registry.REGISTRIES) { // if (registry instanceof IdRegistry) { // initializeRegistry((IdRegistry<?>) registry); // } // } // } // // private Collection<ModCandidate> collectModCandidates() { // ModReportCollector reportCollector = new ModReportCollector(); // ModConstructor constructor = new ModConstructor(this.languageAdapters); // // for (IModReporter reporter : modReporters) { // reporter.apply(reportCollector, constructor); // } // // return reportCollector.getCandidates(); // } // // private <T> void initializeRegistry(IdRegistry<T> registry) { // for (IRegistrationConfig config : installedModContext.getRegistrationConfigs()) { // config.registerEntries(registry); // } // } // } // // Path: src/main/java/net/fabricmc/api/Side.java // public enum Side { // // CLIENT, // SERVER, // UNIVERSAL; // // public boolean hasClient() { // return this != SERVER; // } // // public boolean hasServer() { // return this != CLIENT; // } // // public boolean isClient() { // return this == CLIENT; // } // // public boolean isServer() { // return this == SERVER; // } // // }
import com.openmodloader.api.NestedSupplier; import com.openmodloader.loader.OpenModLoader; import net.fabricmc.api.Side;
package com.openmodloader.api.mod.config; public class SidedModConfigurator implements IModConfigurator { private NestedSupplier<IModConfigurator> common; private NestedSupplier<IModConfigurator> physicalServer; private NestedSupplier<IModConfigurator> physicalClient; public SidedModConfigurator common(NestedSupplier<IModConfigurator> supplier) { this.common = supplier; return this; } public SidedModConfigurator physicalServer(NestedSupplier<IModConfigurator> supplier) { this.physicalServer = supplier; return this; } public SidedModConfigurator physicalClient(NestedSupplier<IModConfigurator> supplier) { this.physicalClient = supplier; return this; } @Override public void configure(IModConfig config) { if (this.common != null) { this.common.get().configure(config); }
// Path: src/main/java/com/openmodloader/api/NestedSupplier.java // @FunctionalInterface // public interface NestedSupplier<T> { // Supplier<T> inner(); // // default T get() { // return this.inner().get(); // } // } // // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java // public final class OpenModLoader { // public static final Version VERSION = Version.valueOf("1.0.0"); // // private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); // // private final ImmutableList<IModReporter> modReporters; // private final ImmutableMap<String, ILanguageAdapter> languageAdapters; // // private static OpenModLoader instance; // private static IGameContext context; // // private IEventDispatcher eventDispatcher = VoidEventDispatcher.INSTANCE; // // private ModContext installedModContext; // private ModContext modContext; // // OpenModLoader(ImmutableList<IModReporter> modReporters, ImmutableMap<String, ILanguageAdapter> languageAdapters) { // this.modReporters = modReporters; // this.languageAdapters = languageAdapters; // } // // public static void offerContext(IGameContext context) { // if (OpenModLoader.context != null) { // throw new IllegalStateException("OmlContext has already been initialized"); // } // OpenModLoader.context = context; // } // // public static void offerInstance(OpenModLoader instance) { // if (OpenModLoader.instance != null) { // throw new IllegalStateException("OpenModLoader has already been initialized!"); // } // OpenModLoader.instance = instance; // } // // public static OpenModLoader get() { // if (instance == null) { // throw new IllegalStateException("OpenModLoader not yet initialized!"); // } // return instance; // } // // public static IGameContext getContext() { // return context; // } // // public IEventDispatcher getEventDispatcher() { // return eventDispatcher; // } // // @Nullable // public ModContext getInstalledModContext() { // return installedModContext; // } // // @Nullable // public ModContext getModContext() { // return modContext; // } // // public void initialize() { // offerInstance(this); // // Collection<ModCandidate> installedCandidates = collectModCandidates(); // LOGGER.info("Collected {} mod candidates", installedCandidates.size()); // // List<Mod> installedMods = installedCandidates.stream() // .map(ModCandidate::construct) // .collect(Collectors.toList()); // // List<Mod> globalMods = installedMods.stream() // .filter(Mod::isGlobal) // .collect(Collectors.toList()); // // installedModContext = new ModContext(installedMods); // modContext = new ModContext(globalMods); // // eventDispatcher = modContext.buildEventDispatcher(); // // for (Registry<?> registry : Registry.REGISTRIES) { // if (registry instanceof IdRegistry) { // initializeRegistry((IdRegistry<?>) registry); // } // } // } // // private Collection<ModCandidate> collectModCandidates() { // ModReportCollector reportCollector = new ModReportCollector(); // ModConstructor constructor = new ModConstructor(this.languageAdapters); // // for (IModReporter reporter : modReporters) { // reporter.apply(reportCollector, constructor); // } // // return reportCollector.getCandidates(); // } // // private <T> void initializeRegistry(IdRegistry<T> registry) { // for (IRegistrationConfig config : installedModContext.getRegistrationConfigs()) { // config.registerEntries(registry); // } // } // } // // Path: src/main/java/net/fabricmc/api/Side.java // public enum Side { // // CLIENT, // SERVER, // UNIVERSAL; // // public boolean hasClient() { // return this != SERVER; // } // // public boolean hasServer() { // return this != CLIENT; // } // // public boolean isClient() { // return this == CLIENT; // } // // public boolean isServer() { // return this == SERVER; // } // // } // Path: src/main/java/com/openmodloader/api/mod/config/SidedModConfigurator.java import com.openmodloader.api.NestedSupplier; import com.openmodloader.loader.OpenModLoader; import net.fabricmc.api.Side; package com.openmodloader.api.mod.config; public class SidedModConfigurator implements IModConfigurator { private NestedSupplier<IModConfigurator> common; private NestedSupplier<IModConfigurator> physicalServer; private NestedSupplier<IModConfigurator> physicalClient; public SidedModConfigurator common(NestedSupplier<IModConfigurator> supplier) { this.common = supplier; return this; } public SidedModConfigurator physicalServer(NestedSupplier<IModConfigurator> supplier) { this.physicalServer = supplier; return this; } public SidedModConfigurator physicalClient(NestedSupplier<IModConfigurator> supplier) { this.physicalClient = supplier; return this; } @Override public void configure(IModConfig config) { if (this.common != null) { this.common.get().configure(config); }
Side physicalSide = OpenModLoader.getContext().getPhysicalSide();
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/api/mod/config/SidedModConfigurator.java
// Path: src/main/java/com/openmodloader/api/NestedSupplier.java // @FunctionalInterface // public interface NestedSupplier<T> { // Supplier<T> inner(); // // default T get() { // return this.inner().get(); // } // } // // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java // public final class OpenModLoader { // public static final Version VERSION = Version.valueOf("1.0.0"); // // private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); // // private final ImmutableList<IModReporter> modReporters; // private final ImmutableMap<String, ILanguageAdapter> languageAdapters; // // private static OpenModLoader instance; // private static IGameContext context; // // private IEventDispatcher eventDispatcher = VoidEventDispatcher.INSTANCE; // // private ModContext installedModContext; // private ModContext modContext; // // OpenModLoader(ImmutableList<IModReporter> modReporters, ImmutableMap<String, ILanguageAdapter> languageAdapters) { // this.modReporters = modReporters; // this.languageAdapters = languageAdapters; // } // // public static void offerContext(IGameContext context) { // if (OpenModLoader.context != null) { // throw new IllegalStateException("OmlContext has already been initialized"); // } // OpenModLoader.context = context; // } // // public static void offerInstance(OpenModLoader instance) { // if (OpenModLoader.instance != null) { // throw new IllegalStateException("OpenModLoader has already been initialized!"); // } // OpenModLoader.instance = instance; // } // // public static OpenModLoader get() { // if (instance == null) { // throw new IllegalStateException("OpenModLoader not yet initialized!"); // } // return instance; // } // // public static IGameContext getContext() { // return context; // } // // public IEventDispatcher getEventDispatcher() { // return eventDispatcher; // } // // @Nullable // public ModContext getInstalledModContext() { // return installedModContext; // } // // @Nullable // public ModContext getModContext() { // return modContext; // } // // public void initialize() { // offerInstance(this); // // Collection<ModCandidate> installedCandidates = collectModCandidates(); // LOGGER.info("Collected {} mod candidates", installedCandidates.size()); // // List<Mod> installedMods = installedCandidates.stream() // .map(ModCandidate::construct) // .collect(Collectors.toList()); // // List<Mod> globalMods = installedMods.stream() // .filter(Mod::isGlobal) // .collect(Collectors.toList()); // // installedModContext = new ModContext(installedMods); // modContext = new ModContext(globalMods); // // eventDispatcher = modContext.buildEventDispatcher(); // // for (Registry<?> registry : Registry.REGISTRIES) { // if (registry instanceof IdRegistry) { // initializeRegistry((IdRegistry<?>) registry); // } // } // } // // private Collection<ModCandidate> collectModCandidates() { // ModReportCollector reportCollector = new ModReportCollector(); // ModConstructor constructor = new ModConstructor(this.languageAdapters); // // for (IModReporter reporter : modReporters) { // reporter.apply(reportCollector, constructor); // } // // return reportCollector.getCandidates(); // } // // private <T> void initializeRegistry(IdRegistry<T> registry) { // for (IRegistrationConfig config : installedModContext.getRegistrationConfigs()) { // config.registerEntries(registry); // } // } // } // // Path: src/main/java/net/fabricmc/api/Side.java // public enum Side { // // CLIENT, // SERVER, // UNIVERSAL; // // public boolean hasClient() { // return this != SERVER; // } // // public boolean hasServer() { // return this != CLIENT; // } // // public boolean isClient() { // return this == CLIENT; // } // // public boolean isServer() { // return this == SERVER; // } // // }
import com.openmodloader.api.NestedSupplier; import com.openmodloader.loader.OpenModLoader; import net.fabricmc.api.Side;
package com.openmodloader.api.mod.config; public class SidedModConfigurator implements IModConfigurator { private NestedSupplier<IModConfigurator> common; private NestedSupplier<IModConfigurator> physicalServer; private NestedSupplier<IModConfigurator> physicalClient; public SidedModConfigurator common(NestedSupplier<IModConfigurator> supplier) { this.common = supplier; return this; } public SidedModConfigurator physicalServer(NestedSupplier<IModConfigurator> supplier) { this.physicalServer = supplier; return this; } public SidedModConfigurator physicalClient(NestedSupplier<IModConfigurator> supplier) { this.physicalClient = supplier; return this; } @Override public void configure(IModConfig config) { if (this.common != null) { this.common.get().configure(config); }
// Path: src/main/java/com/openmodloader/api/NestedSupplier.java // @FunctionalInterface // public interface NestedSupplier<T> { // Supplier<T> inner(); // // default T get() { // return this.inner().get(); // } // } // // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java // public final class OpenModLoader { // public static final Version VERSION = Version.valueOf("1.0.0"); // // private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); // // private final ImmutableList<IModReporter> modReporters; // private final ImmutableMap<String, ILanguageAdapter> languageAdapters; // // private static OpenModLoader instance; // private static IGameContext context; // // private IEventDispatcher eventDispatcher = VoidEventDispatcher.INSTANCE; // // private ModContext installedModContext; // private ModContext modContext; // // OpenModLoader(ImmutableList<IModReporter> modReporters, ImmutableMap<String, ILanguageAdapter> languageAdapters) { // this.modReporters = modReporters; // this.languageAdapters = languageAdapters; // } // // public static void offerContext(IGameContext context) { // if (OpenModLoader.context != null) { // throw new IllegalStateException("OmlContext has already been initialized"); // } // OpenModLoader.context = context; // } // // public static void offerInstance(OpenModLoader instance) { // if (OpenModLoader.instance != null) { // throw new IllegalStateException("OpenModLoader has already been initialized!"); // } // OpenModLoader.instance = instance; // } // // public static OpenModLoader get() { // if (instance == null) { // throw new IllegalStateException("OpenModLoader not yet initialized!"); // } // return instance; // } // // public static IGameContext getContext() { // return context; // } // // public IEventDispatcher getEventDispatcher() { // return eventDispatcher; // } // // @Nullable // public ModContext getInstalledModContext() { // return installedModContext; // } // // @Nullable // public ModContext getModContext() { // return modContext; // } // // public void initialize() { // offerInstance(this); // // Collection<ModCandidate> installedCandidates = collectModCandidates(); // LOGGER.info("Collected {} mod candidates", installedCandidates.size()); // // List<Mod> installedMods = installedCandidates.stream() // .map(ModCandidate::construct) // .collect(Collectors.toList()); // // List<Mod> globalMods = installedMods.stream() // .filter(Mod::isGlobal) // .collect(Collectors.toList()); // // installedModContext = new ModContext(installedMods); // modContext = new ModContext(globalMods); // // eventDispatcher = modContext.buildEventDispatcher(); // // for (Registry<?> registry : Registry.REGISTRIES) { // if (registry instanceof IdRegistry) { // initializeRegistry((IdRegistry<?>) registry); // } // } // } // // private Collection<ModCandidate> collectModCandidates() { // ModReportCollector reportCollector = new ModReportCollector(); // ModConstructor constructor = new ModConstructor(this.languageAdapters); // // for (IModReporter reporter : modReporters) { // reporter.apply(reportCollector, constructor); // } // // return reportCollector.getCandidates(); // } // // private <T> void initializeRegistry(IdRegistry<T> registry) { // for (IRegistrationConfig config : installedModContext.getRegistrationConfigs()) { // config.registerEntries(registry); // } // } // } // // Path: src/main/java/net/fabricmc/api/Side.java // public enum Side { // // CLIENT, // SERVER, // UNIVERSAL; // // public boolean hasClient() { // return this != SERVER; // } // // public boolean hasServer() { // return this != CLIENT; // } // // public boolean isClient() { // return this == CLIENT; // } // // public boolean isServer() { // return this == SERVER; // } // // } // Path: src/main/java/com/openmodloader/api/mod/config/SidedModConfigurator.java import com.openmodloader.api.NestedSupplier; import com.openmodloader.loader.OpenModLoader; import net.fabricmc.api.Side; package com.openmodloader.api.mod.config; public class SidedModConfigurator implements IModConfigurator { private NestedSupplier<IModConfigurator> common; private NestedSupplier<IModConfigurator> physicalServer; private NestedSupplier<IModConfigurator> physicalClient; public SidedModConfigurator common(NestedSupplier<IModConfigurator> supplier) { this.common = supplier; return this; } public SidedModConfigurator physicalServer(NestedSupplier<IModConfigurator> supplier) { this.physicalServer = supplier; return this; } public SidedModConfigurator physicalClient(NestedSupplier<IModConfigurator> supplier) { this.physicalClient = supplier; return this; } @Override public void configure(IModConfig config) { if (this.common != null) { this.common.get().configure(config); }
Side physicalSide = OpenModLoader.getContext().getPhysicalSide();
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // }
import com.google.common.collect.ImmutableList; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget;
package com.openmodloader.api.mod.config; public class SimpleEventConfig implements IEventConfig { private final ImmutableList<Listener<?>> listeners; private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { this.listeners = listeners; } public static Builder builder() { return new Builder(); } @Override
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // } // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java import com.google.common.collect.ImmutableList; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; package com.openmodloader.api.mod.config; public class SimpleEventConfig implements IEventConfig { private final ImmutableList<Listener<?>> listeners; private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { this.listeners = listeners; } public static Builder builder() { return new Builder(); } @Override
public void applyTo(EventMap.Builder builder) {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // }
import com.google.common.collect.ImmutableList; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget;
package com.openmodloader.api.mod.config; public class SimpleEventConfig implements IEventConfig { private final ImmutableList<Listener<?>> listeners; private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { this.listeners = listeners; } public static Builder builder() { return new Builder(); } @Override public void applyTo(EventMap.Builder builder) { for (Listener<?> listener : listeners) { putListener(builder, listener); } }
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // } // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java import com.google.common.collect.ImmutableList; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; package com.openmodloader.api.mod.config; public class SimpleEventConfig implements IEventConfig { private final ImmutableList<Listener<?>> listeners; private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { this.listeners = listeners; } public static Builder builder() { return new Builder(); } @Override public void applyTo(EventMap.Builder builder) { for (Listener<?> listener : listeners) { putListener(builder, listener); } }
private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // }
import com.google.common.collect.ImmutableList; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget;
package com.openmodloader.api.mod.config; public class SimpleEventConfig implements IEventConfig { private final ImmutableList<Listener<?>> listeners; private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { this.listeners = listeners; } public static Builder builder() { return new Builder(); } @Override public void applyTo(EventMap.Builder builder) { for (Listener<?> listener : listeners) { putListener(builder, listener); } } private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { builder.put(listener.target, listener.listener); } public static class Builder { private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); private Builder() { }
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // } // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java import com.google.common.collect.ImmutableList; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; package com.openmodloader.api.mod.config; public class SimpleEventConfig implements IEventConfig { private final ImmutableList<Listener<?>> listeners; private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { this.listeners = listeners; } public static Builder builder() { return new Builder(); } @Override public void applyTo(EventMap.Builder builder) { for (Listener<?> listener : listeners) { putListener(builder, listener); } } private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { builder.put(listener.target, listener.listener); } public static class Builder { private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); private Builder() { }
public <E extends IEvent> Builder listen(IEventTarget<E> target, IEventListener<E> listener) {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // }
import com.google.common.collect.ImmutableList; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget;
package com.openmodloader.api.mod.config; public class SimpleEventConfig implements IEventConfig { private final ImmutableList<Listener<?>> listeners; private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { this.listeners = listeners; } public static Builder builder() { return new Builder(); } @Override public void applyTo(EventMap.Builder builder) { for (Listener<?> listener : listeners) { putListener(builder, listener); } } private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { builder.put(listener.target, listener.listener); } public static class Builder { private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); private Builder() { }
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // } // Path: src/main/java/com/openmodloader/api/mod/config/SimpleEventConfig.java import com.google.common.collect.ImmutableList; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; package com.openmodloader.api.mod.config; public class SimpleEventConfig implements IEventConfig { private final ImmutableList<Listener<?>> listeners; private SimpleEventConfig(ImmutableList<Listener<?>> listeners) { this.listeners = listeners; } public static Builder builder() { return new Builder(); } @Override public void applyTo(EventMap.Builder builder) { for (Listener<?> listener : listeners) { putListener(builder, listener); } } private <E extends IEvent> void putListener(EventMap.Builder builder, Listener<E> listener) { builder.put(listener.target, listener.listener); } public static class Builder { private final ImmutableList.Builder<Listener<?>> listeners = ImmutableList.builder(); private Builder() { }
public <E extends IEvent> Builder listen(IEventTarget<E> target, IEventListener<E> listener) {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/api/mod/Mod.java
// Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // }
import com.openmodloader.api.mod.config.IModConfig;
package com.openmodloader.api.mod; public class Mod { private final ModMetadata metadata;
// Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // Path: src/main/java/com/openmodloader/api/mod/Mod.java import com.openmodloader.api.mod.config.IModConfig; package com.openmodloader.api.mod; public class Mod { private final ModMetadata metadata;
private final IModConfig config;
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/api/IGameContext.java
// Path: src/main/java/net/fabricmc/api/Side.java // public enum Side { // // CLIENT, // SERVER, // UNIVERSAL; // // public boolean hasClient() { // return this != SERVER; // } // // public boolean hasServer() { // return this != CLIENT; // } // // public boolean isClient() { // return this == CLIENT; // } // // public boolean isServer() { // return this == SERVER; // } // // }
import net.fabricmc.api.Side; import net.minecraft.server.MinecraftServer; import javax.annotation.Nullable; import java.io.File;
package com.openmodloader.api; public interface IGameContext { File getRunDirectory(); @Nullable MinecraftServer getServer();
// Path: src/main/java/net/fabricmc/api/Side.java // public enum Side { // // CLIENT, // SERVER, // UNIVERSAL; // // public boolean hasClient() { // return this != SERVER; // } // // public boolean hasServer() { // return this != CLIENT; // } // // public boolean isClient() { // return this == CLIENT; // } // // public boolean isServer() { // return this == SERVER; // } // // } // Path: src/main/java/com/openmodloader/api/IGameContext.java import net.fabricmc.api.Side; import net.minecraft.server.MinecraftServer; import javax.annotation.Nullable; import java.io.File; package com.openmodloader.api; public interface IGameContext { File getRunDirectory(); @Nullable MinecraftServer getServer();
Side getPhysicalSide();
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/ModContext.java
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // }
import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator;
package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods;
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // } // Path: src/main/java/com/openmodloader/loader/ModContext.java import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods;
private final Collection<IEventConfig> eventConfigs = new ArrayList<>();
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/ModContext.java
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // }
import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator;
package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods; private final Collection<IEventConfig> eventConfigs = new ArrayList<>();
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // } // Path: src/main/java/com/openmodloader/loader/ModContext.java import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods; private final Collection<IEventConfig> eventConfigs = new ArrayList<>();
private final Collection<IRegistrationConfig> registrationConfigs = new ArrayList<>();
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/ModContext.java
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // }
import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator;
package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods; private final Collection<IEventConfig> eventConfigs = new ArrayList<>(); private final Collection<IRegistrationConfig> registrationConfigs = new ArrayList<>(); public ModContext(Collection<Mod> mods) { this.mods = mods; for (Mod mod : mods) {
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // } // Path: src/main/java/com/openmodloader/loader/ModContext.java import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods; private final Collection<IEventConfig> eventConfigs = new ArrayList<>(); private final Collection<IRegistrationConfig> registrationConfigs = new ArrayList<>(); public ModContext(Collection<Mod> mods) { this.mods = mods; for (Mod mod : mods) {
IModConfig config = mod.getConfig();
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/ModContext.java
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // }
import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator;
package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods; private final Collection<IEventConfig> eventConfigs = new ArrayList<>(); private final Collection<IRegistrationConfig> registrationConfigs = new ArrayList<>(); public ModContext(Collection<Mod> mods) { this.mods = mods; for (Mod mod : mods) { IModConfig config = mod.getConfig(); eventConfigs.addAll(config.getEventConfigs()); registrationConfigs.addAll(config.getRegistrationConfigs()); } }
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // } // Path: src/main/java/com/openmodloader/loader/ModContext.java import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods; private final Collection<IEventConfig> eventConfigs = new ArrayList<>(); private final Collection<IRegistrationConfig> registrationConfigs = new ArrayList<>(); public ModContext(Collection<Mod> mods) { this.mods = mods; for (Mod mod : mods) { IModConfig config = mod.getConfig(); eventConfigs.addAll(config.getEventConfigs()); registrationConfigs.addAll(config.getRegistrationConfigs()); } }
public IEventDispatcher buildEventDispatcher() {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/ModContext.java
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // }
import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator;
package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods; private final Collection<IEventConfig> eventConfigs = new ArrayList<>(); private final Collection<IRegistrationConfig> registrationConfigs = new ArrayList<>(); public ModContext(Collection<Mod> mods) { this.mods = mods; for (Mod mod : mods) { IModConfig config = mod.getConfig(); eventConfigs.addAll(config.getEventConfigs()); registrationConfigs.addAll(config.getRegistrationConfigs()); } } public IEventDispatcher buildEventDispatcher() {
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // } // Path: src/main/java/com/openmodloader/loader/ModContext.java import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods; private final Collection<IEventConfig> eventConfigs = new ArrayList<>(); private final Collection<IRegistrationConfig> registrationConfigs = new ArrayList<>(); public ModContext(Collection<Mod> mods) { this.mods = mods; for (Mod mod : mods) { IModConfig config = mod.getConfig(); eventConfigs.addAll(config.getEventConfigs()); registrationConfigs.addAll(config.getRegistrationConfigs()); } } public IEventDispatcher buildEventDispatcher() {
EventMap.Builder eventBuilder = EventMap.builder();
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/ModContext.java
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // }
import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator;
package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods; private final Collection<IEventConfig> eventConfigs = new ArrayList<>(); private final Collection<IRegistrationConfig> registrationConfigs = new ArrayList<>(); public ModContext(Collection<Mod> mods) { this.mods = mods; for (Mod mod : mods) { IModConfig config = mod.getConfig(); eventConfigs.addAll(config.getEventConfigs()); registrationConfigs.addAll(config.getRegistrationConfigs()); } } public IEventDispatcher buildEventDispatcher() { EventMap.Builder eventBuilder = EventMap.builder(); for (IEventConfig config : eventConfigs) { config.applyTo(eventBuilder); }
// Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IEventConfig.java // public interface IEventConfig { // void applyTo(EventMap.Builder builder); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfig.java // public interface IModConfig { // default void apply(IModConfigurator configurator) { // configurator.configure(this); // } // // void addEventConfig(IEventConfig config); // // void addRegistrationConfig(IRegistrationConfig config); // // Collection<IEventConfig> getEventConfigs(); // // Collection<IRegistrationConfig> getRegistrationConfigs(); // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java // public class ImmutableEventDispatcher implements IEventDispatcher { // private final EventMap events; // // public ImmutableEventDispatcher(EventMap events) { // this.events = events; // } // // @Override // @SuppressWarnings("unchecked") // public <E extends IEvent> void dispatch(E event) { // IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); // Stream<IEventListener<E>> listeners = this.events.getListeners(target); // // EventContext context = new EventContext(); // listeners.forEach(listener -> listener.handle(event, context)); // } // } // Path: src/main/java/com/openmodloader/loader/ModContext.java import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.config.IEventConfig; import com.openmodloader.api.mod.config.IModConfig; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.ImmutableEventDispatcher; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; package com.openmodloader.loader; public class ModContext implements Iterable<Mod> { private final Collection<Mod> mods; private final Collection<IEventConfig> eventConfigs = new ArrayList<>(); private final Collection<IRegistrationConfig> registrationConfigs = new ArrayList<>(); public ModContext(Collection<Mod> mods) { this.mods = mods; for (Mod mod : mods) { IModConfig config = mod.getConfig(); eventConfigs.addAll(config.getEventConfigs()); registrationConfigs.addAll(config.getRegistrationConfigs()); } } public IEventDispatcher buildEventDispatcher() { EventMap.Builder eventBuilder = EventMap.builder(); for (IEventConfig config : eventConfigs) { config.applyTo(eventBuilder); }
return new ImmutableEventDispatcher(eventBuilder.build());
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/server/ServerGameContext.java
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/net/fabricmc/api/Side.java // public enum Side { // // CLIENT, // SERVER, // UNIVERSAL; // // public boolean hasClient() { // return this != SERVER; // } // // public boolean hasServer() { // return this != CLIENT; // } // // public boolean isClient() { // return this == CLIENT; // } // // public boolean isServer() { // return this == SERVER; // } // // }
import com.openmodloader.api.IGameContext; import net.fabricmc.api.Side; import net.minecraft.server.MinecraftServer; import javax.annotation.Nullable; import java.io.File;
package com.openmodloader.loader.server; public class ServerGameContext implements IGameContext { private final MinecraftServer server; public ServerGameContext(MinecraftServer server) { this.server = server; } @Override public File getRunDirectory() { return this.server.getRunDirectory(); } @Nullable @Override public MinecraftServer getServer() { return this.server; } @Override
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/net/fabricmc/api/Side.java // public enum Side { // // CLIENT, // SERVER, // UNIVERSAL; // // public boolean hasClient() { // return this != SERVER; // } // // public boolean hasServer() { // return this != CLIENT; // } // // public boolean isClient() { // return this == CLIENT; // } // // public boolean isServer() { // return this == SERVER; // } // // } // Path: src/main/java/com/openmodloader/loader/server/ServerGameContext.java import com.openmodloader.api.IGameContext; import net.fabricmc.api.Side; import net.minecraft.server.MinecraftServer; import javax.annotation.Nullable; import java.io.File; package com.openmodloader.loader.server; public class ServerGameContext implements IGameContext { private final MinecraftServer server; public ServerGameContext(MinecraftServer server) { this.server = server; } @Override public File getRunDirectory() { return this.server.getRunDirectory(); } @Nullable @Override public MinecraftServer getServer() { return this.server; } @Override
public Side getPhysicalSide() {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/JavaLanguageAdapter.java
// Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // }
import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.mod.config.IModConfigurator;
package com.openmodloader.loader; public final class JavaLanguageAdapter implements ILanguageAdapter { public static final JavaLanguageAdapter INSTANCE = new JavaLanguageAdapter(); private JavaLanguageAdapter() { } @Override
// Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // Path: src/main/java/com/openmodloader/loader/JavaLanguageAdapter.java import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.mod.config.IModConfigurator; package com.openmodloader.loader; public final class JavaLanguageAdapter implements ILanguageAdapter { public static final JavaLanguageAdapter INSTANCE = new JavaLanguageAdapter(); private JavaLanguageAdapter() { } @Override
public <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/OpenModLoader.java
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // }
import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors;
package com.openmodloader.loader; // TODO: Handling non-global mods, specific to world instances public final class OpenModLoader { public static final Version VERSION = Version.valueOf("1.0.0"); private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class);
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // } // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; package com.openmodloader.loader; // TODO: Handling non-global mods, specific to world instances public final class OpenModLoader { public static final Version VERSION = Version.valueOf("1.0.0"); private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class);
private final ImmutableList<IModReporter> modReporters;
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/OpenModLoader.java
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // }
import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors;
package com.openmodloader.loader; // TODO: Handling non-global mods, specific to world instances public final class OpenModLoader { public static final Version VERSION = Version.valueOf("1.0.0"); private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); private final ImmutableList<IModReporter> modReporters;
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // } // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; package com.openmodloader.loader; // TODO: Handling non-global mods, specific to world instances public final class OpenModLoader { public static final Version VERSION = Version.valueOf("1.0.0"); private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); private final ImmutableList<IModReporter> modReporters;
private final ImmutableMap<String, ILanguageAdapter> languageAdapters;
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/OpenModLoader.java
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // }
import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors;
package com.openmodloader.loader; // TODO: Handling non-global mods, specific to world instances public final class OpenModLoader { public static final Version VERSION = Version.valueOf("1.0.0"); private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); private final ImmutableList<IModReporter> modReporters; private final ImmutableMap<String, ILanguageAdapter> languageAdapters; private static OpenModLoader instance;
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // } // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; package com.openmodloader.loader; // TODO: Handling non-global mods, specific to world instances public final class OpenModLoader { public static final Version VERSION = Version.valueOf("1.0.0"); private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); private final ImmutableList<IModReporter> modReporters; private final ImmutableMap<String, ILanguageAdapter> languageAdapters; private static OpenModLoader instance;
private static IGameContext context;
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/OpenModLoader.java
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // }
import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors;
package com.openmodloader.loader; // TODO: Handling non-global mods, specific to world instances public final class OpenModLoader { public static final Version VERSION = Version.valueOf("1.0.0"); private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); private final ImmutableList<IModReporter> modReporters; private final ImmutableMap<String, ILanguageAdapter> languageAdapters; private static OpenModLoader instance; private static IGameContext context;
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // } // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; package com.openmodloader.loader; // TODO: Handling non-global mods, specific to world instances public final class OpenModLoader { public static final Version VERSION = Version.valueOf("1.0.0"); private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); private final ImmutableList<IModReporter> modReporters; private final ImmutableMap<String, ILanguageAdapter> languageAdapters; private static OpenModLoader instance; private static IGameContext context;
private IEventDispatcher eventDispatcher = VoidEventDispatcher.INSTANCE;
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/OpenModLoader.java
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // }
import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors;
package com.openmodloader.loader; // TODO: Handling non-global mods, specific to world instances public final class OpenModLoader { public static final Version VERSION = Version.valueOf("1.0.0"); private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); private final ImmutableList<IModReporter> modReporters; private final ImmutableMap<String, ILanguageAdapter> languageAdapters; private static OpenModLoader instance; private static IGameContext context;
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // } // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; package com.openmodloader.loader; // TODO: Handling non-global mods, specific to world instances public final class OpenModLoader { public static final Version VERSION = Version.valueOf("1.0.0"); private static Logger LOGGER = LogManager.getFormatterLogger(OpenModLoader.class); private final ImmutableList<IModReporter> modReporters; private final ImmutableMap<String, ILanguageAdapter> languageAdapters; private static OpenModLoader instance; private static IGameContext context;
private IEventDispatcher eventDispatcher = VoidEventDispatcher.INSTANCE;
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/OpenModLoader.java
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // }
import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors;
} public static OpenModLoader get() { if (instance == null) { throw new IllegalStateException("OpenModLoader not yet initialized!"); } return instance; } public static IGameContext getContext() { return context; } public IEventDispatcher getEventDispatcher() { return eventDispatcher; } @Nullable public ModContext getInstalledModContext() { return installedModContext; } @Nullable public ModContext getModContext() { return modContext; } public void initialize() { offerInstance(this);
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // } // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; } public static OpenModLoader get() { if (instance == null) { throw new IllegalStateException("OpenModLoader not yet initialized!"); } return instance; } public static IGameContext getContext() { return context; } public IEventDispatcher getEventDispatcher() { return eventDispatcher; } @Nullable public ModContext getInstalledModContext() { return installedModContext; } @Nullable public ModContext getModContext() { return modContext; } public void initialize() { offerInstance(this);
Collection<ModCandidate> installedCandidates = collectModCandidates();
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/OpenModLoader.java
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // }
import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors;
if (instance == null) { throw new IllegalStateException("OpenModLoader not yet initialized!"); } return instance; } public static IGameContext getContext() { return context; } public IEventDispatcher getEventDispatcher() { return eventDispatcher; } @Nullable public ModContext getInstalledModContext() { return installedModContext; } @Nullable public ModContext getModContext() { return modContext; } public void initialize() { offerInstance(this); Collection<ModCandidate> installedCandidates = collectModCandidates(); LOGGER.info("Collected {} mod candidates", installedCandidates.size());
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // } // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; if (instance == null) { throw new IllegalStateException("OpenModLoader not yet initialized!"); } return instance; } public static IGameContext getContext() { return context; } public IEventDispatcher getEventDispatcher() { return eventDispatcher; } @Nullable public ModContext getInstalledModContext() { return installedModContext; } @Nullable public ModContext getModContext() { return modContext; } public void initialize() { offerInstance(this); Collection<ModCandidate> installedCandidates = collectModCandidates(); LOGGER.info("Collected {} mod candidates", installedCandidates.size());
List<Mod> installedMods = installedCandidates.stream()
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/OpenModLoader.java
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // }
import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors;
.collect(Collectors.toList()); List<Mod> globalMods = installedMods.stream() .filter(Mod::isGlobal) .collect(Collectors.toList()); installedModContext = new ModContext(installedMods); modContext = new ModContext(globalMods); eventDispatcher = modContext.buildEventDispatcher(); for (Registry<?> registry : Registry.REGISTRIES) { if (registry instanceof IdRegistry) { initializeRegistry((IdRegistry<?>) registry); } } } private Collection<ModCandidate> collectModCandidates() { ModReportCollector reportCollector = new ModReportCollector(); ModConstructor constructor = new ModConstructor(this.languageAdapters); for (IModReporter reporter : modReporters) { reporter.apply(reportCollector, constructor); } return reportCollector.getCandidates(); } private <T> void initializeRegistry(IdRegistry<T> registry) {
// Path: src/main/java/com/openmodloader/api/IGameContext.java // public interface IGameContext { // File getRunDirectory(); // // @Nullable // MinecraftServer getServer(); // // Side getPhysicalSide(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/loader/IModReporter.java // public interface IModReporter { // void apply(ModReportCollector collector, ModConstructor constructor); // } // // Path: src/main/java/com/openmodloader/api/mod/Mod.java // public class Mod { // private final ModMetadata metadata; // private final IModConfig config; // private final boolean global; // // public Mod(ModMetadata metadata, IModConfig config, boolean global) { // this.metadata = metadata; // this.config = config; // this.global = global; // } // // public ModMetadata getMetadata() { // return metadata; // } // // public IModConfig getConfig() { // return config; // } // // public boolean isGlobal() { // return global; // } // // @Override // public boolean equals(Object obj) { // if (obj == this) return true; // if (obj == null || obj.getClass() != getClass()) return false; // // return ((Mod) obj).metadata.equals(metadata); // } // // @Override // public int hashCode() { // return this.metadata.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/ModCandidate.java // public class ModCandidate { // private final ModMetadata metadata; // private final IModConfigurator configurator; // private boolean global; // // public ModCandidate(ModMetadata metadata, IModConfigurator configurator) { // this.metadata = metadata; // this.configurator = configurator; // } // // public ModCandidate global() { // global = true; // return this; // } // // public boolean isGlobal() { // return global; // } // // public Mod construct() { // IModConfig config = configurator.initConfig(); // configurator.configure(config); // // return new Mod(metadata, config, global); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IRegistrationConfig.java // public interface IRegistrationConfig { // <T> void registerEntries(IdRegistry<T> registry); // } // // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java // public final class VoidEventDispatcher implements IEventDispatcher { // public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); // // private VoidEventDispatcher() { // } // // @Override // public <E extends IEvent> void dispatch(E event) { // } // } // Path: src/main/java/com/openmodloader/loader/OpenModLoader.java import com.github.zafarkhaja.semver.Version; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openmodloader.api.IGameContext; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.loader.IModReporter; import com.openmodloader.api.mod.Mod; import com.openmodloader.api.mod.ModCandidate; import com.openmodloader.api.mod.config.IRegistrationConfig; import com.openmodloader.core.event.VoidEventDispatcher; import net.minecraft.registry.IdRegistry; import net.minecraft.registry.Registry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; .collect(Collectors.toList()); List<Mod> globalMods = installedMods.stream() .filter(Mod::isGlobal) .collect(Collectors.toList()); installedModContext = new ModContext(installedMods); modContext = new ModContext(globalMods); eventDispatcher = modContext.buildEventDispatcher(); for (Registry<?> registry : Registry.REGISTRIES) { if (registry instanceof IdRegistry) { initializeRegistry((IdRegistry<?>) registry); } } } private Collection<ModCandidate> collectModCandidates() { ModReportCollector reportCollector = new ModReportCollector(); ModConstructor constructor = new ModConstructor(this.languageAdapters); for (IModReporter reporter : modReporters) { reporter.apply(reportCollector, constructor); } return reportCollector.getCandidates(); } private <T> void initializeRegistry(IdRegistry<T> registry) {
for (IRegistrationConfig config : installedModContext.getRegistrationConfigs()) {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/core/event/GuiEvent.java
// Path: src/main/java/com/openmodloader/api/event/GenericEventTarget.java // public class GenericEventTarget<E extends IEvent, G> implements IEventTarget<E> { // private final Class<E> eventType; // private final Class<G> genericType; // // protected GenericEventTarget(Class<E> eventType, Class<G> genericType) { // this.eventType = eventType; // this.genericType = genericType; // } // // @SuppressWarnings("unchecked") // public static <E extends IEvent, G> GenericEventTarget<E, G> of(Class<?> eventClass, Class<?> genericType) { // return new GenericEventTarget<>((Class<E>) eventClass, (Class<G>) genericType); // } // // @Override // public Class<E> getType() { // return this.eventType; // } // // @Override // public boolean canReceive(IEventTarget<?> target) { // if (target.getType().equals(this.eventType)) { // if (target instanceof GenericEventTarget) { // GenericEventTarget<?, ?> genericTarget = (GenericEventTarget<?, ?>) target; // return this.genericType.isAssignableFrom(genericTarget.genericType); // } // return true; // } // return false; // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // }
import com.openmodloader.api.event.GenericEventTarget; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventTarget; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.render.text.TextRenderer;
package com.openmodloader.core.event; public abstract class GuiEvent<T extends GuiScreen> implements IEvent { protected final T gui; public GuiEvent(T gui) { this.gui = gui; } public T getGui() { return gui; } public static class Open<T extends GuiScreen> extends GuiEvent<T> { public Open(T gui) { super(gui); } @Override
// Path: src/main/java/com/openmodloader/api/event/GenericEventTarget.java // public class GenericEventTarget<E extends IEvent, G> implements IEventTarget<E> { // private final Class<E> eventType; // private final Class<G> genericType; // // protected GenericEventTarget(Class<E> eventType, Class<G> genericType) { // this.eventType = eventType; // this.genericType = genericType; // } // // @SuppressWarnings("unchecked") // public static <E extends IEvent, G> GenericEventTarget<E, G> of(Class<?> eventClass, Class<?> genericType) { // return new GenericEventTarget<>((Class<E>) eventClass, (Class<G>) genericType); // } // // @Override // public Class<E> getType() { // return this.eventType; // } // // @Override // public boolean canReceive(IEventTarget<?> target) { // if (target.getType().equals(this.eventType)) { // if (target instanceof GenericEventTarget) { // GenericEventTarget<?, ?> genericTarget = (GenericEventTarget<?, ?>) target; // return this.genericType.isAssignableFrom(genericTarget.genericType); // } // return true; // } // return false; // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // } // Path: src/main/java/com/openmodloader/core/event/GuiEvent.java import com.openmodloader.api.event.GenericEventTarget; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventTarget; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.render.text.TextRenderer; package com.openmodloader.core.event; public abstract class GuiEvent<T extends GuiScreen> implements IEvent { protected final T gui; public GuiEvent(T gui) { this.gui = gui; } public T getGui() { return gui; } public static class Open<T extends GuiScreen> extends GuiEvent<T> { public Open(T gui) { super(gui); } @Override
public IEventTarget<?> makeTarget() {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/core/event/GuiEvent.java
// Path: src/main/java/com/openmodloader/api/event/GenericEventTarget.java // public class GenericEventTarget<E extends IEvent, G> implements IEventTarget<E> { // private final Class<E> eventType; // private final Class<G> genericType; // // protected GenericEventTarget(Class<E> eventType, Class<G> genericType) { // this.eventType = eventType; // this.genericType = genericType; // } // // @SuppressWarnings("unchecked") // public static <E extends IEvent, G> GenericEventTarget<E, G> of(Class<?> eventClass, Class<?> genericType) { // return new GenericEventTarget<>((Class<E>) eventClass, (Class<G>) genericType); // } // // @Override // public Class<E> getType() { // return this.eventType; // } // // @Override // public boolean canReceive(IEventTarget<?> target) { // if (target.getType().equals(this.eventType)) { // if (target instanceof GenericEventTarget) { // GenericEventTarget<?, ?> genericTarget = (GenericEventTarget<?, ?>) target; // return this.genericType.isAssignableFrom(genericTarget.genericType); // } // return true; // } // return false; // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // }
import com.openmodloader.api.event.GenericEventTarget; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventTarget; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.render.text.TextRenderer;
package com.openmodloader.core.event; public abstract class GuiEvent<T extends GuiScreen> implements IEvent { protected final T gui; public GuiEvent(T gui) { this.gui = gui; } public T getGui() { return gui; } public static class Open<T extends GuiScreen> extends GuiEvent<T> { public Open(T gui) { super(gui); } @Override public IEventTarget<?> makeTarget() { return target(gui.getClass()); } public static <T extends GuiScreen> IEventTarget<Open<T>> target(Class<T> target) {
// Path: src/main/java/com/openmodloader/api/event/GenericEventTarget.java // public class GenericEventTarget<E extends IEvent, G> implements IEventTarget<E> { // private final Class<E> eventType; // private final Class<G> genericType; // // protected GenericEventTarget(Class<E> eventType, Class<G> genericType) { // this.eventType = eventType; // this.genericType = genericType; // } // // @SuppressWarnings("unchecked") // public static <E extends IEvent, G> GenericEventTarget<E, G> of(Class<?> eventClass, Class<?> genericType) { // return new GenericEventTarget<>((Class<E>) eventClass, (Class<G>) genericType); // } // // @Override // public Class<E> getType() { // return this.eventType; // } // // @Override // public boolean canReceive(IEventTarget<?> target) { // if (target.getType().equals(this.eventType)) { // if (target instanceof GenericEventTarget) { // GenericEventTarget<?, ?> genericTarget = (GenericEventTarget<?, ?>) target; // return this.genericType.isAssignableFrom(genericTarget.genericType); // } // return true; // } // return false; // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // } // Path: src/main/java/com/openmodloader/core/event/GuiEvent.java import com.openmodloader.api.event.GenericEventTarget; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventTarget; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.render.text.TextRenderer; package com.openmodloader.core.event; public abstract class GuiEvent<T extends GuiScreen> implements IEvent { protected final T gui; public GuiEvent(T gui) { this.gui = gui; } public T getGui() { return gui; } public static class Open<T extends GuiScreen> extends GuiEvent<T> { public Open(T gui) { super(gui); } @Override public IEventTarget<?> makeTarget() { return target(gui.getClass()); } public static <T extends GuiScreen> IEventTarget<Open<T>> target(Class<T> target) {
return GenericEventTarget.of(Open.class, target);
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // }
import com.openmodloader.api.event.EventContext; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; import java.util.stream.Stream;
package com.openmodloader.core.event; public class ImmutableEventDispatcher implements IEventDispatcher { private final EventMap events; public ImmutableEventDispatcher(EventMap events) { this.events = events; } @Override @SuppressWarnings("unchecked")
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // } // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java import com.openmodloader.api.event.EventContext; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; import java.util.stream.Stream; package com.openmodloader.core.event; public class ImmutableEventDispatcher implements IEventDispatcher { private final EventMap events; public ImmutableEventDispatcher(EventMap events) { this.events = events; } @Override @SuppressWarnings("unchecked")
public <E extends IEvent> void dispatch(E event) {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // }
import com.openmodloader.api.event.EventContext; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; import java.util.stream.Stream;
package com.openmodloader.core.event; public class ImmutableEventDispatcher implements IEventDispatcher { private final EventMap events; public ImmutableEventDispatcher(EventMap events) { this.events = events; } @Override @SuppressWarnings("unchecked") public <E extends IEvent> void dispatch(E event) {
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // } // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java import com.openmodloader.api.event.EventContext; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; import java.util.stream.Stream; package com.openmodloader.core.event; public class ImmutableEventDispatcher implements IEventDispatcher { private final EventMap events; public ImmutableEventDispatcher(EventMap events) { this.events = events; } @Override @SuppressWarnings("unchecked") public <E extends IEvent> void dispatch(E event) {
IEventTarget<E> target = (IEventTarget<E>) event.makeTarget();
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // }
import com.openmodloader.api.event.EventContext; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; import java.util.stream.Stream;
package com.openmodloader.core.event; public class ImmutableEventDispatcher implements IEventDispatcher { private final EventMap events; public ImmutableEventDispatcher(EventMap events) { this.events = events; } @Override @SuppressWarnings("unchecked") public <E extends IEvent> void dispatch(E event) { IEventTarget<E> target = (IEventTarget<E>) event.makeTarget();
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // } // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java import com.openmodloader.api.event.EventContext; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; import java.util.stream.Stream; package com.openmodloader.core.event; public class ImmutableEventDispatcher implements IEventDispatcher { private final EventMap events; public ImmutableEventDispatcher(EventMap events) { this.events = events; } @Override @SuppressWarnings("unchecked") public <E extends IEvent> void dispatch(E event) { IEventTarget<E> target = (IEventTarget<E>) event.makeTarget();
Stream<IEventListener<E>> listeners = this.events.getListeners(target);
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // }
import com.openmodloader.api.event.EventContext; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; import java.util.stream.Stream;
package com.openmodloader.core.event; public class ImmutableEventDispatcher implements IEventDispatcher { private final EventMap events; public ImmutableEventDispatcher(EventMap events) { this.events = events; } @Override @SuppressWarnings("unchecked") public <E extends IEvent> void dispatch(E event) { IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); Stream<IEventListener<E>> listeners = this.events.getListeners(target);
// Path: src/main/java/com/openmodloader/api/event/EventContext.java // public class EventContext { // } // // Path: src/main/java/com/openmodloader/api/event/EventMap.java // public class EventMap { // private final ImmutableMap<Class<?>, Collection<Listener<?>>> events; // // private EventMap(ImmutableMap<Class<?>, Collection<Listener<?>>> events) { // this.events = events; // } // // @SuppressWarnings("unchecked") // public <E extends IEvent> Stream<IEventListener<E>> getListeners(IEventTarget<E> target) { // Collection<Listener<?>> listeners = this.events.get(target.getType()); // if (listeners == null) { // return Stream.empty(); // } // // return listeners.stream() // .filter(l -> l.canReceive(target)) // .map(l -> (IEventListener<E>) l.listener); // } // // public static Builder builder() { // return new Builder(); // } // // public static class Builder { // private final Map<Class<?>, Collection<Listener<?>>> events = new HashMap<>(); // // private Builder() { // } // // public <E extends IEvent> Builder put(IEventTarget<E> target, IEventListener<E> listener) { // Class<E> targetType = target.getType(); // Collection<Listener<?>> listeners = this.events.computeIfAbsent(targetType, t -> new ArrayList<>()); // listeners.add(new Listener<>(target, listener)); // return this; // } // // public EventMap build() { // return new EventMap(ImmutableMap.copyOf(this.events)); // } // } // // private static class Listener<E extends IEvent> { // private final IEventTarget<E> target; // private final IEventListener<E> listener; // // private Listener(IEventTarget<E> target, IEventListener<E> listener) { // this.target = target; // this.listener = listener; // } // // boolean canReceive(IEventTarget<?> target) { // return this.target.canReceive(target); // } // } // } // // Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // // Path: src/main/java/com/openmodloader/api/event/IEventListener.java // @FunctionalInterface // public interface IEventListener<E extends IEvent> { // void handle(E event, EventContext context); // } // // Path: src/main/java/com/openmodloader/api/event/IEventTarget.java // public interface IEventTarget<E extends IEvent> { // Class<E> getType(); // // boolean canReceive(IEventTarget<?> target); // } // Path: src/main/java/com/openmodloader/core/event/ImmutableEventDispatcher.java import com.openmodloader.api.event.EventContext; import com.openmodloader.api.event.EventMap; import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher; import com.openmodloader.api.event.IEventListener; import com.openmodloader.api.event.IEventTarget; import java.util.stream.Stream; package com.openmodloader.core.event; public class ImmutableEventDispatcher implements IEventDispatcher { private final EventMap events; public ImmutableEventDispatcher(EventMap events) { this.events = events; } @Override @SuppressWarnings("unchecked") public <E extends IEvent> void dispatch(E event) { IEventTarget<E> target = (IEventTarget<E>) event.makeTarget(); Stream<IEventListener<E>> listeners = this.events.getListeners(target);
EventContext context = new EventContext();
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/ModConstructor.java
// Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // }
import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.mod.config.IModConfigurator; import java.util.Map;
package com.openmodloader.loader; public class ModConstructor { private final Map<String, ILanguageAdapter> languageAdapters; public ModConstructor(Map<String, ILanguageAdapter> languageAdapters) { this.languageAdapters = languageAdapters; }
// Path: src/main/java/com/openmodloader/api/loader/ILanguageAdapter.java // public interface ILanguageAdapter { // <T extends IModConfigurator> T constructConfigurator(Class<T> modClass) throws ModConstructionException; // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // Path: src/main/java/com/openmodloader/loader/ModConstructor.java import com.openmodloader.api.loader.ILanguageAdapter; import com.openmodloader.api.mod.config.IModConfigurator; import java.util.Map; package com.openmodloader.loader; public class ModConstructor { private final Map<String, ILanguageAdapter> languageAdapters; public ModConstructor(Map<String, ILanguageAdapter> languageAdapters) { this.languageAdapters = languageAdapters; }
public <T extends IModConfigurator> T constructConfigurator(Class<T> configuratorClass, String adapterType) throws ModConstructionException {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/parse/ModDeclaration.java
// Path: src/main/java/com/openmodloader/api/mod/ModMetadata.java // public class ModMetadata { // private final String id; // private final Version version; // // public ModMetadata(String id, Version version) { // this.id = id; // this.version = version; // } // // public String getId() { // return id; // } // // public Version getVersion() { // return version; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) return true; // if (obj == null || getClass() != obj.getClass()) return false; // // ModMetadata metadata = (ModMetadata) obj; // return metadata.id.equals(id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/loader/ModConstructionException.java // public class ModConstructionException extends Exception { // public ModConstructionException() { // } // // public ModConstructionException(String message) { // super(message); // } // // public ModConstructionException(String message, Throwable cause) { // super(message, cause); // } // // public ModConstructionException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/com/openmodloader/loader/ModConstructor.java // public class ModConstructor { // private final Map<String, ILanguageAdapter> languageAdapters; // // public ModConstructor(Map<String, ILanguageAdapter> languageAdapters) { // this.languageAdapters = languageAdapters; // } // // public <T extends IModConfigurator> T constructConfigurator(Class<T> configuratorClass, String adapterType) throws ModConstructionException { // ILanguageAdapter adapter = this.languageAdapters.getOrDefault(adapterType, JavaLanguageAdapter.INSTANCE); // return adapter.constructConfigurator(configuratorClass); // } // }
import com.github.zafarkhaja.semver.Version; import com.openmodloader.api.mod.ModMetadata; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.loader.ModConstructionException; import com.openmodloader.loader.ModConstructor; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List;
private static void validate(ModDeclaration declaration) throws ParseException { if (declaration.id == null) { throw new ParseException("Id must be specified in mod declaration!"); } if (declaration.configurator == null || declaration.configurator.path == null) { throw new ParseException("Mod configurator was not specified for '" + declaration.id + "'!"); } } public String getId() { return id; } public String getName() { return name != null ? name : id; } public String getVersion() { return version; } public String getConfigurator() { return configurator.path; } public String getAdapter() { return configurator.adapter; }
// Path: src/main/java/com/openmodloader/api/mod/ModMetadata.java // public class ModMetadata { // private final String id; // private final Version version; // // public ModMetadata(String id, Version version) { // this.id = id; // this.version = version; // } // // public String getId() { // return id; // } // // public Version getVersion() { // return version; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) return true; // if (obj == null || getClass() != obj.getClass()) return false; // // ModMetadata metadata = (ModMetadata) obj; // return metadata.id.equals(id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/loader/ModConstructionException.java // public class ModConstructionException extends Exception { // public ModConstructionException() { // } // // public ModConstructionException(String message) { // super(message); // } // // public ModConstructionException(String message, Throwable cause) { // super(message, cause); // } // // public ModConstructionException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/com/openmodloader/loader/ModConstructor.java // public class ModConstructor { // private final Map<String, ILanguageAdapter> languageAdapters; // // public ModConstructor(Map<String, ILanguageAdapter> languageAdapters) { // this.languageAdapters = languageAdapters; // } // // public <T extends IModConfigurator> T constructConfigurator(Class<T> configuratorClass, String adapterType) throws ModConstructionException { // ILanguageAdapter adapter = this.languageAdapters.getOrDefault(adapterType, JavaLanguageAdapter.INSTANCE); // return adapter.constructConfigurator(configuratorClass); // } // } // Path: src/main/java/com/openmodloader/loader/parse/ModDeclaration.java import com.github.zafarkhaja.semver.Version; import com.openmodloader.api.mod.ModMetadata; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.loader.ModConstructionException; import com.openmodloader.loader.ModConstructor; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; private static void validate(ModDeclaration declaration) throws ParseException { if (declaration.id == null) { throw new ParseException("Id must be specified in mod declaration!"); } if (declaration.configurator == null || declaration.configurator.path == null) { throw new ParseException("Mod configurator was not specified for '" + declaration.id + "'!"); } } public String getId() { return id; } public String getName() { return name != null ? name : id; } public String getVersion() { return version; } public String getConfigurator() { return configurator.path; } public String getAdapter() { return configurator.adapter; }
public ModMetadata buildMetadata() {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/parse/ModDeclaration.java
// Path: src/main/java/com/openmodloader/api/mod/ModMetadata.java // public class ModMetadata { // private final String id; // private final Version version; // // public ModMetadata(String id, Version version) { // this.id = id; // this.version = version; // } // // public String getId() { // return id; // } // // public Version getVersion() { // return version; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) return true; // if (obj == null || getClass() != obj.getClass()) return false; // // ModMetadata metadata = (ModMetadata) obj; // return metadata.id.equals(id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/loader/ModConstructionException.java // public class ModConstructionException extends Exception { // public ModConstructionException() { // } // // public ModConstructionException(String message) { // super(message); // } // // public ModConstructionException(String message, Throwable cause) { // super(message, cause); // } // // public ModConstructionException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/com/openmodloader/loader/ModConstructor.java // public class ModConstructor { // private final Map<String, ILanguageAdapter> languageAdapters; // // public ModConstructor(Map<String, ILanguageAdapter> languageAdapters) { // this.languageAdapters = languageAdapters; // } // // public <T extends IModConfigurator> T constructConfigurator(Class<T> configuratorClass, String adapterType) throws ModConstructionException { // ILanguageAdapter adapter = this.languageAdapters.getOrDefault(adapterType, JavaLanguageAdapter.INSTANCE); // return adapter.constructConfigurator(configuratorClass); // } // }
import com.github.zafarkhaja.semver.Version; import com.openmodloader.api.mod.ModMetadata; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.loader.ModConstructionException; import com.openmodloader.loader.ModConstructor; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List;
public String getId() { return id; } public String getName() { return name != null ? name : id; } public String getVersion() { return version; } public String getConfigurator() { return configurator.path; } public String getAdapter() { return configurator.adapter; } public ModMetadata buildMetadata() { return new ModMetadata(id, Version.valueOf(version)); } public Collection<ModDeclaration> getChildren() { return Collections.unmodifiableCollection(children.mods); } @SuppressWarnings("unchecked")
// Path: src/main/java/com/openmodloader/api/mod/ModMetadata.java // public class ModMetadata { // private final String id; // private final Version version; // // public ModMetadata(String id, Version version) { // this.id = id; // this.version = version; // } // // public String getId() { // return id; // } // // public Version getVersion() { // return version; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) return true; // if (obj == null || getClass() != obj.getClass()) return false; // // ModMetadata metadata = (ModMetadata) obj; // return metadata.id.equals(id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/loader/ModConstructionException.java // public class ModConstructionException extends Exception { // public ModConstructionException() { // } // // public ModConstructionException(String message) { // super(message); // } // // public ModConstructionException(String message, Throwable cause) { // super(message, cause); // } // // public ModConstructionException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/com/openmodloader/loader/ModConstructor.java // public class ModConstructor { // private final Map<String, ILanguageAdapter> languageAdapters; // // public ModConstructor(Map<String, ILanguageAdapter> languageAdapters) { // this.languageAdapters = languageAdapters; // } // // public <T extends IModConfigurator> T constructConfigurator(Class<T> configuratorClass, String adapterType) throws ModConstructionException { // ILanguageAdapter adapter = this.languageAdapters.getOrDefault(adapterType, JavaLanguageAdapter.INSTANCE); // return adapter.constructConfigurator(configuratorClass); // } // } // Path: src/main/java/com/openmodloader/loader/parse/ModDeclaration.java import com.github.zafarkhaja.semver.Version; import com.openmodloader.api.mod.ModMetadata; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.loader.ModConstructionException; import com.openmodloader.loader.ModConstructor; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public String getId() { return id; } public String getName() { return name != null ? name : id; } public String getVersion() { return version; } public String getConfigurator() { return configurator.path; } public String getAdapter() { return configurator.adapter; } public ModMetadata buildMetadata() { return new ModMetadata(id, Version.valueOf(version)); } public Collection<ModDeclaration> getChildren() { return Collections.unmodifiableCollection(children.mods); } @SuppressWarnings("unchecked")
public IModConfigurator constructConfigurator(ModConstructor constructor) throws ModConstructionException {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/parse/ModDeclaration.java
// Path: src/main/java/com/openmodloader/api/mod/ModMetadata.java // public class ModMetadata { // private final String id; // private final Version version; // // public ModMetadata(String id, Version version) { // this.id = id; // this.version = version; // } // // public String getId() { // return id; // } // // public Version getVersion() { // return version; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) return true; // if (obj == null || getClass() != obj.getClass()) return false; // // ModMetadata metadata = (ModMetadata) obj; // return metadata.id.equals(id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/loader/ModConstructionException.java // public class ModConstructionException extends Exception { // public ModConstructionException() { // } // // public ModConstructionException(String message) { // super(message); // } // // public ModConstructionException(String message, Throwable cause) { // super(message, cause); // } // // public ModConstructionException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/com/openmodloader/loader/ModConstructor.java // public class ModConstructor { // private final Map<String, ILanguageAdapter> languageAdapters; // // public ModConstructor(Map<String, ILanguageAdapter> languageAdapters) { // this.languageAdapters = languageAdapters; // } // // public <T extends IModConfigurator> T constructConfigurator(Class<T> configuratorClass, String adapterType) throws ModConstructionException { // ILanguageAdapter adapter = this.languageAdapters.getOrDefault(adapterType, JavaLanguageAdapter.INSTANCE); // return adapter.constructConfigurator(configuratorClass); // } // }
import com.github.zafarkhaja.semver.Version; import com.openmodloader.api.mod.ModMetadata; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.loader.ModConstructionException; import com.openmodloader.loader.ModConstructor; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List;
public String getId() { return id; } public String getName() { return name != null ? name : id; } public String getVersion() { return version; } public String getConfigurator() { return configurator.path; } public String getAdapter() { return configurator.adapter; } public ModMetadata buildMetadata() { return new ModMetadata(id, Version.valueOf(version)); } public Collection<ModDeclaration> getChildren() { return Collections.unmodifiableCollection(children.mods); } @SuppressWarnings("unchecked")
// Path: src/main/java/com/openmodloader/api/mod/ModMetadata.java // public class ModMetadata { // private final String id; // private final Version version; // // public ModMetadata(String id, Version version) { // this.id = id; // this.version = version; // } // // public String getId() { // return id; // } // // public Version getVersion() { // return version; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) return true; // if (obj == null || getClass() != obj.getClass()) return false; // // ModMetadata metadata = (ModMetadata) obj; // return metadata.id.equals(id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/loader/ModConstructionException.java // public class ModConstructionException extends Exception { // public ModConstructionException() { // } // // public ModConstructionException(String message) { // super(message); // } // // public ModConstructionException(String message, Throwable cause) { // super(message, cause); // } // // public ModConstructionException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/com/openmodloader/loader/ModConstructor.java // public class ModConstructor { // private final Map<String, ILanguageAdapter> languageAdapters; // // public ModConstructor(Map<String, ILanguageAdapter> languageAdapters) { // this.languageAdapters = languageAdapters; // } // // public <T extends IModConfigurator> T constructConfigurator(Class<T> configuratorClass, String adapterType) throws ModConstructionException { // ILanguageAdapter adapter = this.languageAdapters.getOrDefault(adapterType, JavaLanguageAdapter.INSTANCE); // return adapter.constructConfigurator(configuratorClass); // } // } // Path: src/main/java/com/openmodloader/loader/parse/ModDeclaration.java import com.github.zafarkhaja.semver.Version; import com.openmodloader.api.mod.ModMetadata; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.loader.ModConstructionException; import com.openmodloader.loader.ModConstructor; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public String getId() { return id; } public String getName() { return name != null ? name : id; } public String getVersion() { return version; } public String getConfigurator() { return configurator.path; } public String getAdapter() { return configurator.adapter; } public ModMetadata buildMetadata() { return new ModMetadata(id, Version.valueOf(version)); } public Collection<ModDeclaration> getChildren() { return Collections.unmodifiableCollection(children.mods); } @SuppressWarnings("unchecked")
public IModConfigurator constructConfigurator(ModConstructor constructor) throws ModConstructionException {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/parse/ModDeclaration.java
// Path: src/main/java/com/openmodloader/api/mod/ModMetadata.java // public class ModMetadata { // private final String id; // private final Version version; // // public ModMetadata(String id, Version version) { // this.id = id; // this.version = version; // } // // public String getId() { // return id; // } // // public Version getVersion() { // return version; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) return true; // if (obj == null || getClass() != obj.getClass()) return false; // // ModMetadata metadata = (ModMetadata) obj; // return metadata.id.equals(id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/loader/ModConstructionException.java // public class ModConstructionException extends Exception { // public ModConstructionException() { // } // // public ModConstructionException(String message) { // super(message); // } // // public ModConstructionException(String message, Throwable cause) { // super(message, cause); // } // // public ModConstructionException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/com/openmodloader/loader/ModConstructor.java // public class ModConstructor { // private final Map<String, ILanguageAdapter> languageAdapters; // // public ModConstructor(Map<String, ILanguageAdapter> languageAdapters) { // this.languageAdapters = languageAdapters; // } // // public <T extends IModConfigurator> T constructConfigurator(Class<T> configuratorClass, String adapterType) throws ModConstructionException { // ILanguageAdapter adapter = this.languageAdapters.getOrDefault(adapterType, JavaLanguageAdapter.INSTANCE); // return adapter.constructConfigurator(configuratorClass); // } // }
import com.github.zafarkhaja.semver.Version; import com.openmodloader.api.mod.ModMetadata; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.loader.ModConstructionException; import com.openmodloader.loader.ModConstructor; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List;
public String getId() { return id; } public String getName() { return name != null ? name : id; } public String getVersion() { return version; } public String getConfigurator() { return configurator.path; } public String getAdapter() { return configurator.adapter; } public ModMetadata buildMetadata() { return new ModMetadata(id, Version.valueOf(version)); } public Collection<ModDeclaration> getChildren() { return Collections.unmodifiableCollection(children.mods); } @SuppressWarnings("unchecked")
// Path: src/main/java/com/openmodloader/api/mod/ModMetadata.java // public class ModMetadata { // private final String id; // private final Version version; // // public ModMetadata(String id, Version version) { // this.id = id; // this.version = version; // } // // public String getId() { // return id; // } // // public Version getVersion() { // return version; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) return true; // if (obj == null || getClass() != obj.getClass()) return false; // // ModMetadata metadata = (ModMetadata) obj; // return metadata.id.equals(id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/com/openmodloader/api/mod/config/IModConfigurator.java // public interface IModConfigurator { // default IModConfig initConfig() { // return new SimpleModConfig(); // } // // void configure(IModConfig config); // } // // Path: src/main/java/com/openmodloader/loader/ModConstructionException.java // public class ModConstructionException extends Exception { // public ModConstructionException() { // } // // public ModConstructionException(String message) { // super(message); // } // // public ModConstructionException(String message, Throwable cause) { // super(message, cause); // } // // public ModConstructionException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/com/openmodloader/loader/ModConstructor.java // public class ModConstructor { // private final Map<String, ILanguageAdapter> languageAdapters; // // public ModConstructor(Map<String, ILanguageAdapter> languageAdapters) { // this.languageAdapters = languageAdapters; // } // // public <T extends IModConfigurator> T constructConfigurator(Class<T> configuratorClass, String adapterType) throws ModConstructionException { // ILanguageAdapter adapter = this.languageAdapters.getOrDefault(adapterType, JavaLanguageAdapter.INSTANCE); // return adapter.constructConfigurator(configuratorClass); // } // } // Path: src/main/java/com/openmodloader/loader/parse/ModDeclaration.java import com.github.zafarkhaja.semver.Version; import com.openmodloader.api.mod.ModMetadata; import com.openmodloader.api.mod.config.IModConfigurator; import com.openmodloader.loader.ModConstructionException; import com.openmodloader.loader.ModConstructor; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public String getId() { return id; } public String getName() { return name != null ? name : id; } public String getVersion() { return version; } public String getConfigurator() { return configurator.path; } public String getAdapter() { return configurator.adapter; } public ModMetadata buildMetadata() { return new ModMetadata(id, Version.valueOf(version)); } public Collection<ModDeclaration> getChildren() { return Collections.unmodifiableCollection(children.mods); } @SuppressWarnings("unchecked")
public IModConfigurator constructConfigurator(ModConstructor constructor) throws ModConstructionException {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/loader/launch/OMLServiceProvider.java
// Path: src/main/java/net/fabricmc/api/Side.java // public enum Side { // // CLIENT, // SERVER, // UNIVERSAL; // // public boolean hasClient() { // return this != SERVER; // } // // public boolean hasServer() { // return this != CLIENT; // } // // public boolean isClient() { // return this == CLIENT; // } // // public boolean isServer() { // return this == SERVER; // } // // }
import cpw.mods.modlauncher.api.IEnvironment; import cpw.mods.modlauncher.api.ITransformationService; import cpw.mods.modlauncher.api.ITransformer; import cpw.mods.modlauncher.api.IncompatibleEnvironmentException; import me.modmuss50.fusion.MixinManager; import me.modmuss50.fusion.transformer.MixinTransformer; import net.fabricmc.api.Side; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nonnull; import java.util.*;
package com.openmodloader.loader.launch; public class OMLServiceProvider implements ITransformationService { protected static Logger LOGGER = LogManager.getFormatterLogger("OpenModLoader"); @Nonnull @Override public String name() { return "oml"; } @Override public void initialize(IEnvironment environment) { LOGGER.info("Hello Mod Launcher!"); Map<String, String> data = new HashMap<>();
// Path: src/main/java/net/fabricmc/api/Side.java // public enum Side { // // CLIENT, // SERVER, // UNIVERSAL; // // public boolean hasClient() { // return this != SERVER; // } // // public boolean hasServer() { // return this != CLIENT; // } // // public boolean isClient() { // return this == CLIENT; // } // // public boolean isServer() { // return this == SERVER; // } // // } // Path: src/main/java/com/openmodloader/loader/launch/OMLServiceProvider.java import cpw.mods.modlauncher.api.IEnvironment; import cpw.mods.modlauncher.api.ITransformationService; import cpw.mods.modlauncher.api.ITransformer; import cpw.mods.modlauncher.api.IncompatibleEnvironmentException; import me.modmuss50.fusion.MixinManager; import me.modmuss50.fusion.transformer.MixinTransformer; import net.fabricmc.api.Side; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.Nonnull; import java.util.*; package com.openmodloader.loader.launch; public class OMLServiceProvider implements ITransformationService { protected static Logger LOGGER = LogManager.getFormatterLogger("OpenModLoader"); @Nonnull @Override public String name() { return "oml"; } @Override public void initialize(IEnvironment environment) { LOGGER.info("Hello Mod Launcher!"); Map<String, String> data = new HashMap<>();
data.put("side", (System.getProperty("omlServer", "false").equals("true") ? Side.SERVER : Side.CLIENT).name()); //TODO find a good way to get the side
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/core/event/ChainedEventDispatcher.java
// Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // }
import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher;
package com.openmodloader.core.event; public class ChainedEventDispatcher implements IEventDispatcher { private final IEventDispatcher[] dispatchers; public ChainedEventDispatcher(IEventDispatcher[] dispatchers) { this.dispatchers = dispatchers; } @Override
// Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // Path: src/main/java/com/openmodloader/core/event/ChainedEventDispatcher.java import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher; package com.openmodloader.core.event; public class ChainedEventDispatcher implements IEventDispatcher { private final IEventDispatcher[] dispatchers; public ChainedEventDispatcher(IEventDispatcher[] dispatchers) { this.dispatchers = dispatchers; } @Override
public <E extends IEvent> void dispatch(E event) {
OpenModLoader/OpenModLoader
src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java
// Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // }
import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher;
package com.openmodloader.core.event; public final class VoidEventDispatcher implements IEventDispatcher { public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); private VoidEventDispatcher() { } @Override
// Path: src/main/java/com/openmodloader/api/event/IEvent.java // public interface IEvent { // IEventTarget<?> makeTarget(); // } // // Path: src/main/java/com/openmodloader/api/event/IEventDispatcher.java // public interface IEventDispatcher { // <E extends IEvent> void dispatch(E event); // } // Path: src/main/java/com/openmodloader/core/event/VoidEventDispatcher.java import com.openmodloader.api.event.IEvent; import com.openmodloader.api.event.IEventDispatcher; package com.openmodloader.core.event; public final class VoidEventDispatcher implements IEventDispatcher { public static final VoidEventDispatcher INSTANCE = new VoidEventDispatcher(); private VoidEventDispatcher() { } @Override
public <E extends IEvent> void dispatch(E event) {
zsoltk/overpasser
library/src/test/java/hu/supercluster/overpasser/library/query/OverpassQueryTest.java
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputFormat.java // public enum OutputFormat { // /** // * Request the result in JSON format // */ // JSON, // // /** // * Request the result in XML format // */ // XML, // // /** // * Request the result in CSV format // */ // CSV, // }
import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.*; import static org.hamcrest.CoreMatchers.isA; import static org.junit.Assert.*; import static org.mockito.Mockito.verify;
@Test public void testTimeout() throws Exception { query.timeout(30); verify(builder).setting("timeout", "30"); } @Test public void testBoundingBox() throws Exception { query.boundingBox(1.00000001, 2.00000002, 3.00000003, 4.00000004); verify(builder).append("[bbox:1.00000001,2.00000002,3.00000003,4.00000004]"); } @Test public void testFilterQuery() throws Exception { OverpassFilterQuery filterQuery = query.filterQuery(); assertThat(filterQuery, isA(OverpassFilterQuery.class)); } @Test public void testOutputWithDefaultArgs() throws Exception { query.output(100); verify(builder).append("; out body center qt 100"); } @Test public void testOutputWithCustomArgs() throws Exception {
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputFormat.java // public enum OutputFormat { // /** // * Request the result in JSON format // */ // JSON, // // /** // * Request the result in XML format // */ // XML, // // /** // * Request the result in CSV format // */ // CSV, // } // Path: library/src/test/java/hu/supercluster/overpasser/library/query/OverpassQueryTest.java import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.*; import static org.hamcrest.CoreMatchers.isA; import static org.junit.Assert.*; import static org.mockito.Mockito.verify; @Test public void testTimeout() throws Exception { query.timeout(30); verify(builder).setting("timeout", "30"); } @Test public void testBoundingBox() throws Exception { query.boundingBox(1.00000001, 2.00000002, 3.00000003, 4.00000004); verify(builder).append("[bbox:1.00000001,2.00000002,3.00000003,4.00000004]"); } @Test public void testFilterQuery() throws Exception { OverpassFilterQuery filterQuery = query.filterQuery(); assertThat(filterQuery, isA(OverpassFilterQuery.class)); } @Test public void testOutputWithDefaultArgs() throws Exception { query.output(100); verify(builder).append("; out body center qt 100"); } @Test public void testOutputWithCustomArgs() throws Exception {
query.output(OutputVerbosity.META, OutputModificator.GEOM, OutputOrder.ASC, 100);
zsoltk/overpasser
library/src/test/java/hu/supercluster/overpasser/library/query/OverpassQueryTest.java
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputFormat.java // public enum OutputFormat { // /** // * Request the result in JSON format // */ // JSON, // // /** // * Request the result in XML format // */ // XML, // // /** // * Request the result in CSV format // */ // CSV, // }
import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.*; import static org.hamcrest.CoreMatchers.isA; import static org.junit.Assert.*; import static org.mockito.Mockito.verify;
@Test public void testTimeout() throws Exception { query.timeout(30); verify(builder).setting("timeout", "30"); } @Test public void testBoundingBox() throws Exception { query.boundingBox(1.00000001, 2.00000002, 3.00000003, 4.00000004); verify(builder).append("[bbox:1.00000001,2.00000002,3.00000003,4.00000004]"); } @Test public void testFilterQuery() throws Exception { OverpassFilterQuery filterQuery = query.filterQuery(); assertThat(filterQuery, isA(OverpassFilterQuery.class)); } @Test public void testOutputWithDefaultArgs() throws Exception { query.output(100); verify(builder).append("; out body center qt 100"); } @Test public void testOutputWithCustomArgs() throws Exception {
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputFormat.java // public enum OutputFormat { // /** // * Request the result in JSON format // */ // JSON, // // /** // * Request the result in XML format // */ // XML, // // /** // * Request the result in CSV format // */ // CSV, // } // Path: library/src/test/java/hu/supercluster/overpasser/library/query/OverpassQueryTest.java import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.*; import static org.hamcrest.CoreMatchers.isA; import static org.junit.Assert.*; import static org.mockito.Mockito.verify; @Test public void testTimeout() throws Exception { query.timeout(30); verify(builder).setting("timeout", "30"); } @Test public void testBoundingBox() throws Exception { query.boundingBox(1.00000001, 2.00000002, 3.00000003, 4.00000004); verify(builder).append("[bbox:1.00000001,2.00000002,3.00000003,4.00000004]"); } @Test public void testFilterQuery() throws Exception { OverpassFilterQuery filterQuery = query.filterQuery(); assertThat(filterQuery, isA(OverpassFilterQuery.class)); } @Test public void testOutputWithDefaultArgs() throws Exception { query.output(100); verify(builder).append("; out body center qt 100"); } @Test public void testOutputWithCustomArgs() throws Exception {
query.output(OutputVerbosity.META, OutputModificator.GEOM, OutputOrder.ASC, 100);
zsoltk/overpasser
library/src/test/java/hu/supercluster/overpasser/library/query/OverpassQueryTest.java
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputFormat.java // public enum OutputFormat { // /** // * Request the result in JSON format // */ // JSON, // // /** // * Request the result in XML format // */ // XML, // // /** // * Request the result in CSV format // */ // CSV, // }
import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.*; import static org.hamcrest.CoreMatchers.isA; import static org.junit.Assert.*; import static org.mockito.Mockito.verify;
@Test public void testTimeout() throws Exception { query.timeout(30); verify(builder).setting("timeout", "30"); } @Test public void testBoundingBox() throws Exception { query.boundingBox(1.00000001, 2.00000002, 3.00000003, 4.00000004); verify(builder).append("[bbox:1.00000001,2.00000002,3.00000003,4.00000004]"); } @Test public void testFilterQuery() throws Exception { OverpassFilterQuery filterQuery = query.filterQuery(); assertThat(filterQuery, isA(OverpassFilterQuery.class)); } @Test public void testOutputWithDefaultArgs() throws Exception { query.output(100); verify(builder).append("; out body center qt 100"); } @Test public void testOutputWithCustomArgs() throws Exception {
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputFormat.java // public enum OutputFormat { // /** // * Request the result in JSON format // */ // JSON, // // /** // * Request the result in XML format // */ // XML, // // /** // * Request the result in CSV format // */ // CSV, // } // Path: library/src/test/java/hu/supercluster/overpasser/library/query/OverpassQueryTest.java import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.*; import static org.hamcrest.CoreMatchers.isA; import static org.junit.Assert.*; import static org.mockito.Mockito.verify; @Test public void testTimeout() throws Exception { query.timeout(30); verify(builder).setting("timeout", "30"); } @Test public void testBoundingBox() throws Exception { query.boundingBox(1.00000001, 2.00000002, 3.00000003, 4.00000004); verify(builder).append("[bbox:1.00000001,2.00000002,3.00000003,4.00000004]"); } @Test public void testFilterQuery() throws Exception { OverpassFilterQuery filterQuery = query.filterQuery(); assertThat(filterQuery, isA(OverpassFilterQuery.class)); } @Test public void testOutputWithDefaultArgs() throws Exception { query.output(100); verify(builder).append("; out body center qt 100"); } @Test public void testOutputWithCustomArgs() throws Exception {
query.output(OutputVerbosity.META, OutputModificator.GEOM, OutputOrder.ASC, 100);
zsoltk/overpasser
sample/src/main/java/hu/supercluster/overpasser/app/activity/container/MapUiHandler.java
// Path: sample/src/main/java/hu/supercluster/overpasser/app/util/LocationHelper.java // @EBean // public class LocationHelper { // @SystemService // LocationManager locationManager; // // public Location getLastKnownLocation() { // Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); // // if (location == null) { // location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); // } // // if (location == null) { // location = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER); // } // // return location; // } // } // // Path: sample/src/main/java/hu/supercluster/overpasser/app/view/PoiInfoWindowAdapter.java // @EBean(scope = EBean.Scope.Singleton) // public class PoiInfoWindowAdapter implements GoogleMap.InfoWindowAdapter { // private Map<String, OverpassQueryResult.Element> map; // // @RootContext // Context context; // // public PoiInfoWindowAdapter() { // map = new HashMap<>(); // } // // public void addMarkerInfo(Marker marker, OverpassQueryResult.Element poi) { // map.put(marker.getId(), poi); // } // // @Override // public View getInfoWindow(Marker marker) { // return null; // } // // @Override // @DebugLog // public View getInfoContents(Marker marker) { // Element poi = getElement(marker); // // if (poi != null) { // return createView(poi); // // } else { // return null; // } // } // // private Element getElement(Marker marker) { // return map.get(marker.getId()); // } // // @NonNull // private View createView(Element poi) { // PoiInfoWindowView view = PoiInfoWindowView_.build(context); // view.setTitle(poi.tags.name); // view.setBody(getPoiDescription(poi)); // // return view; // } // // String getPoiDescription(Element poi) { // StringBuilder builder = new StringBuilder(); // Element.Tags info = poi.tags; // // builder.append(getLine(getAddressLine1(info))); // builder.append(getLine(getAddressLine2(info))); // builder.append(getLine(info.phone)); // builder.append(getLine(info.website)); // builder.append("\n"); // builder.append(getLine(info.wheelchairDescription)); // builder.append(getLine(getFeeInfo(info))); // // return builder.toString().trim(); // } // // private String getFeeInfo(Element.Tags info) { // return getBooleanInfo(info.fee, R.string.poi_info_payant); // } // // @Nullable // private String getBooleanInfo(String info, int label) { // if (info != null) { // Resources resources = context.getResources(); // int i = mapChoice(info); // // return String.format("%s: %s", // resources.getString(label), // i > 0 ? resources.getString(i) : info // ); // // } else { // return null; // } // } // // private String getAddressLine1(Element.Tags info) { // return info.addressCity; // } // // private String getAddressLine2(Element.Tags info) { // StringBuilder builder = new StringBuilder(); // // if (info.addressStreet != null) { // builder.append(info.addressStreet); // builder.append(" "); // } // // if (info.addressHouseNumber != null) { // builder.append(info.addressHouseNumber); // builder.append("."); // } // // return builder.toString().trim(); // } // // String getLine(String text) { // return text == null ? "" : text + "\n"; // } // // private int mapChoice(String choice) { // switch (choice.toLowerCase()) { // case "yes": // case "designated": // return R.string.yes; // // case "limited": // return R.string.limited; // // case "no": // return R.string.no; // // default: // return 0; // } // } // }
import android.location.Location; import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.LatLng; import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.EBean; import hu.supercluster.overpasser.app.util.LocationHelper; import hu.supercluster.overpasser.app.view.PoiInfoWindowAdapter; import static com.google.android.gms.maps.GoogleMap.MAP_TYPE_NORMAL;
package hu.supercluster.overpasser.app.activity.container; @EBean public class MapUiHandler { private MapFragment fragment; @Bean
// Path: sample/src/main/java/hu/supercluster/overpasser/app/util/LocationHelper.java // @EBean // public class LocationHelper { // @SystemService // LocationManager locationManager; // // public Location getLastKnownLocation() { // Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); // // if (location == null) { // location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); // } // // if (location == null) { // location = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER); // } // // return location; // } // } // // Path: sample/src/main/java/hu/supercluster/overpasser/app/view/PoiInfoWindowAdapter.java // @EBean(scope = EBean.Scope.Singleton) // public class PoiInfoWindowAdapter implements GoogleMap.InfoWindowAdapter { // private Map<String, OverpassQueryResult.Element> map; // // @RootContext // Context context; // // public PoiInfoWindowAdapter() { // map = new HashMap<>(); // } // // public void addMarkerInfo(Marker marker, OverpassQueryResult.Element poi) { // map.put(marker.getId(), poi); // } // // @Override // public View getInfoWindow(Marker marker) { // return null; // } // // @Override // @DebugLog // public View getInfoContents(Marker marker) { // Element poi = getElement(marker); // // if (poi != null) { // return createView(poi); // // } else { // return null; // } // } // // private Element getElement(Marker marker) { // return map.get(marker.getId()); // } // // @NonNull // private View createView(Element poi) { // PoiInfoWindowView view = PoiInfoWindowView_.build(context); // view.setTitle(poi.tags.name); // view.setBody(getPoiDescription(poi)); // // return view; // } // // String getPoiDescription(Element poi) { // StringBuilder builder = new StringBuilder(); // Element.Tags info = poi.tags; // // builder.append(getLine(getAddressLine1(info))); // builder.append(getLine(getAddressLine2(info))); // builder.append(getLine(info.phone)); // builder.append(getLine(info.website)); // builder.append("\n"); // builder.append(getLine(info.wheelchairDescription)); // builder.append(getLine(getFeeInfo(info))); // // return builder.toString().trim(); // } // // private String getFeeInfo(Element.Tags info) { // return getBooleanInfo(info.fee, R.string.poi_info_payant); // } // // @Nullable // private String getBooleanInfo(String info, int label) { // if (info != null) { // Resources resources = context.getResources(); // int i = mapChoice(info); // // return String.format("%s: %s", // resources.getString(label), // i > 0 ? resources.getString(i) : info // ); // // } else { // return null; // } // } // // private String getAddressLine1(Element.Tags info) { // return info.addressCity; // } // // private String getAddressLine2(Element.Tags info) { // StringBuilder builder = new StringBuilder(); // // if (info.addressStreet != null) { // builder.append(info.addressStreet); // builder.append(" "); // } // // if (info.addressHouseNumber != null) { // builder.append(info.addressHouseNumber); // builder.append("."); // } // // return builder.toString().trim(); // } // // String getLine(String text) { // return text == null ? "" : text + "\n"; // } // // private int mapChoice(String choice) { // switch (choice.toLowerCase()) { // case "yes": // case "designated": // return R.string.yes; // // case "limited": // return R.string.limited; // // case "no": // return R.string.no; // // default: // return 0; // } // } // } // Path: sample/src/main/java/hu/supercluster/overpasser/app/activity/container/MapUiHandler.java import android.location.Location; import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.LatLng; import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.EBean; import hu.supercluster.overpasser.app.util.LocationHelper; import hu.supercluster.overpasser.app.view.PoiInfoWindowAdapter; import static com.google.android.gms.maps.GoogleMap.MAP_TYPE_NORMAL; package hu.supercluster.overpasser.app.activity.container; @EBean public class MapUiHandler { private MapFragment fragment; @Bean
LocationHelper locationHelper;
zsoltk/overpasser
sample/src/main/java/hu/supercluster/overpasser/app/activity/container/MapUiHandler.java
// Path: sample/src/main/java/hu/supercluster/overpasser/app/util/LocationHelper.java // @EBean // public class LocationHelper { // @SystemService // LocationManager locationManager; // // public Location getLastKnownLocation() { // Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); // // if (location == null) { // location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); // } // // if (location == null) { // location = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER); // } // // return location; // } // } // // Path: sample/src/main/java/hu/supercluster/overpasser/app/view/PoiInfoWindowAdapter.java // @EBean(scope = EBean.Scope.Singleton) // public class PoiInfoWindowAdapter implements GoogleMap.InfoWindowAdapter { // private Map<String, OverpassQueryResult.Element> map; // // @RootContext // Context context; // // public PoiInfoWindowAdapter() { // map = new HashMap<>(); // } // // public void addMarkerInfo(Marker marker, OverpassQueryResult.Element poi) { // map.put(marker.getId(), poi); // } // // @Override // public View getInfoWindow(Marker marker) { // return null; // } // // @Override // @DebugLog // public View getInfoContents(Marker marker) { // Element poi = getElement(marker); // // if (poi != null) { // return createView(poi); // // } else { // return null; // } // } // // private Element getElement(Marker marker) { // return map.get(marker.getId()); // } // // @NonNull // private View createView(Element poi) { // PoiInfoWindowView view = PoiInfoWindowView_.build(context); // view.setTitle(poi.tags.name); // view.setBody(getPoiDescription(poi)); // // return view; // } // // String getPoiDescription(Element poi) { // StringBuilder builder = new StringBuilder(); // Element.Tags info = poi.tags; // // builder.append(getLine(getAddressLine1(info))); // builder.append(getLine(getAddressLine2(info))); // builder.append(getLine(info.phone)); // builder.append(getLine(info.website)); // builder.append("\n"); // builder.append(getLine(info.wheelchairDescription)); // builder.append(getLine(getFeeInfo(info))); // // return builder.toString().trim(); // } // // private String getFeeInfo(Element.Tags info) { // return getBooleanInfo(info.fee, R.string.poi_info_payant); // } // // @Nullable // private String getBooleanInfo(String info, int label) { // if (info != null) { // Resources resources = context.getResources(); // int i = mapChoice(info); // // return String.format("%s: %s", // resources.getString(label), // i > 0 ? resources.getString(i) : info // ); // // } else { // return null; // } // } // // private String getAddressLine1(Element.Tags info) { // return info.addressCity; // } // // private String getAddressLine2(Element.Tags info) { // StringBuilder builder = new StringBuilder(); // // if (info.addressStreet != null) { // builder.append(info.addressStreet); // builder.append(" "); // } // // if (info.addressHouseNumber != null) { // builder.append(info.addressHouseNumber); // builder.append("."); // } // // return builder.toString().trim(); // } // // String getLine(String text) { // return text == null ? "" : text + "\n"; // } // // private int mapChoice(String choice) { // switch (choice.toLowerCase()) { // case "yes": // case "designated": // return R.string.yes; // // case "limited": // return R.string.limited; // // case "no": // return R.string.no; // // default: // return 0; // } // } // }
import android.location.Location; import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.LatLng; import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.EBean; import hu.supercluster.overpasser.app.util.LocationHelper; import hu.supercluster.overpasser.app.view.PoiInfoWindowAdapter; import static com.google.android.gms.maps.GoogleMap.MAP_TYPE_NORMAL;
package hu.supercluster.overpasser.app.activity.container; @EBean public class MapUiHandler { private MapFragment fragment; @Bean LocationHelper locationHelper; @Bean
// Path: sample/src/main/java/hu/supercluster/overpasser/app/util/LocationHelper.java // @EBean // public class LocationHelper { // @SystemService // LocationManager locationManager; // // public Location getLastKnownLocation() { // Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); // // if (location == null) { // location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); // } // // if (location == null) { // location = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER); // } // // return location; // } // } // // Path: sample/src/main/java/hu/supercluster/overpasser/app/view/PoiInfoWindowAdapter.java // @EBean(scope = EBean.Scope.Singleton) // public class PoiInfoWindowAdapter implements GoogleMap.InfoWindowAdapter { // private Map<String, OverpassQueryResult.Element> map; // // @RootContext // Context context; // // public PoiInfoWindowAdapter() { // map = new HashMap<>(); // } // // public void addMarkerInfo(Marker marker, OverpassQueryResult.Element poi) { // map.put(marker.getId(), poi); // } // // @Override // public View getInfoWindow(Marker marker) { // return null; // } // // @Override // @DebugLog // public View getInfoContents(Marker marker) { // Element poi = getElement(marker); // // if (poi != null) { // return createView(poi); // // } else { // return null; // } // } // // private Element getElement(Marker marker) { // return map.get(marker.getId()); // } // // @NonNull // private View createView(Element poi) { // PoiInfoWindowView view = PoiInfoWindowView_.build(context); // view.setTitle(poi.tags.name); // view.setBody(getPoiDescription(poi)); // // return view; // } // // String getPoiDescription(Element poi) { // StringBuilder builder = new StringBuilder(); // Element.Tags info = poi.tags; // // builder.append(getLine(getAddressLine1(info))); // builder.append(getLine(getAddressLine2(info))); // builder.append(getLine(info.phone)); // builder.append(getLine(info.website)); // builder.append("\n"); // builder.append(getLine(info.wheelchairDescription)); // builder.append(getLine(getFeeInfo(info))); // // return builder.toString().trim(); // } // // private String getFeeInfo(Element.Tags info) { // return getBooleanInfo(info.fee, R.string.poi_info_payant); // } // // @Nullable // private String getBooleanInfo(String info, int label) { // if (info != null) { // Resources resources = context.getResources(); // int i = mapChoice(info); // // return String.format("%s: %s", // resources.getString(label), // i > 0 ? resources.getString(i) : info // ); // // } else { // return null; // } // } // // private String getAddressLine1(Element.Tags info) { // return info.addressCity; // } // // private String getAddressLine2(Element.Tags info) { // StringBuilder builder = new StringBuilder(); // // if (info.addressStreet != null) { // builder.append(info.addressStreet); // builder.append(" "); // } // // if (info.addressHouseNumber != null) { // builder.append(info.addressHouseNumber); // builder.append("."); // } // // return builder.toString().trim(); // } // // String getLine(String text) { // return text == null ? "" : text + "\n"; // } // // private int mapChoice(String choice) { // switch (choice.toLowerCase()) { // case "yes": // case "designated": // return R.string.yes; // // case "limited": // return R.string.limited; // // case "no": // return R.string.no; // // default: // return 0; // } // } // } // Path: sample/src/main/java/hu/supercluster/overpasser/app/activity/container/MapUiHandler.java import android.location.Location; import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.LatLng; import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.EBean; import hu.supercluster.overpasser.app.util.LocationHelper; import hu.supercluster.overpasser.app.view.PoiInfoWindowAdapter; import static com.google.android.gms.maps.GoogleMap.MAP_TYPE_NORMAL; package hu.supercluster.overpasser.app.activity.container; @EBean public class MapUiHandler { private MapFragment fragment; @Bean LocationHelper locationHelper; @Bean
PoiInfoWindowAdapter poiInfoWindowAdapter;
zsoltk/overpasser
library/src/main/java/hu/supercluster/overpasser/library/query/OverpassQuery.java
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputFormat.java // public enum OutputFormat { // /** // * Request the result in JSON format // */ // JSON, // // /** // * Request the result in XML format // */ // XML, // // /** // * Request the result in CSV format // */ // CSV, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // }
import java.util.Locale; import hu.supercluster.overpasser.library.output.OutputFormat; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputModificator.*; import static hu.supercluster.overpasser.library.output.OutputOrder.*; import static hu.supercluster.overpasser.library.output.OutputVerbosity.*;
package hu.supercluster.overpasser.library.query; /** * The main query class to create and build requests using the Overpass QL */ public class OverpassQuery extends AbstractOverpassQuery { public OverpassQuery() { super(); } OverpassQuery(OverpassQueryBuilder builder) { super(builder); } /** * Controls the output format used to return OSM data. * * @see <a href="http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Output_Format_.28out.29"> * http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Output_Format_.28out.29</a> * * @param outputFormat the OutputFormat to use * * @return the current OverpassQuery object */
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputFormat.java // public enum OutputFormat { // /** // * Request the result in JSON format // */ // JSON, // // /** // * Request the result in XML format // */ // XML, // // /** // * Request the result in CSV format // */ // CSV, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // Path: library/src/main/java/hu/supercluster/overpasser/library/query/OverpassQuery.java import java.util.Locale; import hu.supercluster.overpasser.library.output.OutputFormat; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputModificator.*; import static hu.supercluster.overpasser.library.output.OutputOrder.*; import static hu.supercluster.overpasser.library.output.OutputVerbosity.*; package hu.supercluster.overpasser.library.query; /** * The main query class to create and build requests using the Overpass QL */ public class OverpassQuery extends AbstractOverpassQuery { public OverpassQuery() { super(); } OverpassQuery(OverpassQueryBuilder builder) { super(builder); } /** * Controls the output format used to return OSM data. * * @see <a href="http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Output_Format_.28out.29"> * http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Output_Format_.28out.29</a> * * @param outputFormat the OutputFormat to use * * @return the current OverpassQuery object */
public OverpassQuery format(OutputFormat outputFormat) {
zsoltk/overpasser
library/src/test/java/hu/supercluster/overpasser/library/query/UsageExamplesTest.java
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // }
import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.JSON; import static org.junit.Assert.assertEquals;
package hu.supercluster.overpasser.library.query; public class UsageExamplesTest { @Mock OverpassQueryBuilder builder; private OverpassQuery query; public UsageExamplesTest() { MockitoAnnotations.initMocks(this); } @Before public void setUp() throws Exception { query = new OverpassQuery(builder); } @Test public void testSimpleFilterQuery() throws Exception { String result = new OverpassQuery() .format(JSON) .timeout(30) .filterQuery() .node() .amenity("parking") .tagNot("access", "private") .boundingBox( 47.48047027491862, 19.039797484874725, 47.51331674014172, 19.07404761761427 ) .end()
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // Path: library/src/test/java/hu/supercluster/overpasser/library/query/UsageExamplesTest.java import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.JSON; import static org.junit.Assert.assertEquals; package hu.supercluster.overpasser.library.query; public class UsageExamplesTest { @Mock OverpassQueryBuilder builder; private OverpassQuery query; public UsageExamplesTest() { MockitoAnnotations.initMocks(this); } @Before public void setUp() throws Exception { query = new OverpassQuery(builder); } @Test public void testSimpleFilterQuery() throws Exception { String result = new OverpassQuery() .format(JSON) .timeout(30) .filterQuery() .node() .amenity("parking") .tagNot("access", "private") .boundingBox( 47.48047027491862, 19.039797484874725, 47.51331674014172, 19.07404761761427 ) .end()
.output(OutputVerbosity.BODY, OutputModificator.CENTER, OutputOrder.QT, 100)
zsoltk/overpasser
library/src/test/java/hu/supercluster/overpasser/library/query/UsageExamplesTest.java
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // }
import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.JSON; import static org.junit.Assert.assertEquals;
package hu.supercluster.overpasser.library.query; public class UsageExamplesTest { @Mock OverpassQueryBuilder builder; private OverpassQuery query; public UsageExamplesTest() { MockitoAnnotations.initMocks(this); } @Before public void setUp() throws Exception { query = new OverpassQuery(builder); } @Test public void testSimpleFilterQuery() throws Exception { String result = new OverpassQuery() .format(JSON) .timeout(30) .filterQuery() .node() .amenity("parking") .tagNot("access", "private") .boundingBox( 47.48047027491862, 19.039797484874725, 47.51331674014172, 19.07404761761427 ) .end()
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // Path: library/src/test/java/hu/supercluster/overpasser/library/query/UsageExamplesTest.java import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.JSON; import static org.junit.Assert.assertEquals; package hu.supercluster.overpasser.library.query; public class UsageExamplesTest { @Mock OverpassQueryBuilder builder; private OverpassQuery query; public UsageExamplesTest() { MockitoAnnotations.initMocks(this); } @Before public void setUp() throws Exception { query = new OverpassQuery(builder); } @Test public void testSimpleFilterQuery() throws Exception { String result = new OverpassQuery() .format(JSON) .timeout(30) .filterQuery() .node() .amenity("parking") .tagNot("access", "private") .boundingBox( 47.48047027491862, 19.039797484874725, 47.51331674014172, 19.07404761761427 ) .end()
.output(OutputVerbosity.BODY, OutputModificator.CENTER, OutputOrder.QT, 100)
zsoltk/overpasser
library/src/test/java/hu/supercluster/overpasser/library/query/UsageExamplesTest.java
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // }
import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.JSON; import static org.junit.Assert.assertEquals;
package hu.supercluster.overpasser.library.query; public class UsageExamplesTest { @Mock OverpassQueryBuilder builder; private OverpassQuery query; public UsageExamplesTest() { MockitoAnnotations.initMocks(this); } @Before public void setUp() throws Exception { query = new OverpassQuery(builder); } @Test public void testSimpleFilterQuery() throws Exception { String result = new OverpassQuery() .format(JSON) .timeout(30) .filterQuery() .node() .amenity("parking") .tagNot("access", "private") .boundingBox( 47.48047027491862, 19.039797484874725, 47.51331674014172, 19.07404761761427 ) .end()
// Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputModificator.java // public enum OutputModificator { // /** // * Adds the bounding box of each element to the element. // * For nodes this is equivalent to "geom". // * For ways it is the enclosing bounding box of all nodes. // * For relations it is the enclosing bounding box of all node and way members, // * relations as members have no effect. // */ // BB, // // /** // * This adds the center of the above mentioned bounding box to ways and relations. // * Note: The center point is not guaranteed to lie inside the polygon // */ // CENTER, // // /** // * Add the full geometry to each object. // * This adds coordinates to each node, to each node member of a way or relation, // * and it adds a sequence of "nd" members with coordinates to all relations. // */ // GEOM, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputOrder.java // public enum OutputOrder { // /** // * Sort the output by object id // */ // ASC, // // /** // * Sort by quadtile index; // * this is roughly geographical and significantly faster than order by ids. // */ // QT, // } // // Path: library/src/main/java/hu/supercluster/overpasser/library/output/OutputVerbosity.java // public enum OutputVerbosity { // /** // * Print only the ids of the elements // */ // IDS, // // /** // * Print also the information necessary for geometry. // * These are also coordinates for nodes and way and relation member ids for ways and relations. // */ // SKEL, // // /** // * Print all information necessary to use the data. // * These are also tags for all elements and the roles for relation members. // */ // BODY, // // /** // * Print only ids and tags for each element and not coordinates or members. // */ // TAGS, // // /** // * Print everything known about the elements. // * This includes additionally to body for all elements the version, changeset id, // * timestamp and the user data of the user that last touched the object. // */ // META, // } // Path: library/src/test/java/hu/supercluster/overpasser/library/query/UsageExamplesTest.java import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import hu.supercluster.overpasser.library.output.OutputModificator; import hu.supercluster.overpasser.library.output.OutputOrder; import hu.supercluster.overpasser.library.output.OutputVerbosity; import static hu.supercluster.overpasser.library.output.OutputFormat.JSON; import static org.junit.Assert.assertEquals; package hu.supercluster.overpasser.library.query; public class UsageExamplesTest { @Mock OverpassQueryBuilder builder; private OverpassQuery query; public UsageExamplesTest() { MockitoAnnotations.initMocks(this); } @Before public void setUp() throws Exception { query = new OverpassQuery(builder); } @Test public void testSimpleFilterQuery() throws Exception { String result = new OverpassQuery() .format(JSON) .timeout(30) .filterQuery() .node() .amenity("parking") .tagNot("access", "private") .boundingBox( 47.48047027491862, 19.039797484874725, 47.51331674014172, 19.07404761761427 ) .end()
.output(OutputVerbosity.BODY, OutputModificator.CENTER, OutputOrder.QT, 100)
zsoltk/overpasser
sample/src/main/java/hu/supercluster/overpasser/app/view/PoiInfoWindowAdapter.java
// Path: library-retrofit-legacy-adapter/src/main/java/hu/supercluster/overpasser/adapter/OverpassQueryResult.java // public class OverpassQueryResult { // @SerializedName("elements") // public List<Element> elements = new ArrayList<>(); // // public static class Element { // @SerializedName("type") // public String type; // // @SerializedName("id") // public long id; // // @SerializedName("lat") // public double lat; // // @SerializedName("lon") // public double lon; // // @SerializedName("tags") // public Tags tags = new Tags(); // // public static class Tags { // @SerializedName("type") // public String type; // // @SerializedName("amenity") // public String amenity; // // @SerializedName("name") // public String name; // // @SerializedName("phone") // public String phone; // // @SerializedName("contact:email") // public String contactEmail; // // @SerializedName("website") // public String website; // // @SerializedName("addr:city") // public String addressCity; // // @SerializedName("addr:postcode") // public String addressPostCode; // // @SerializedName("addr:street") // public String addressStreet; // // @SerializedName("addr:housenumber") // public String addressHouseNumber; // // @SerializedName("wheelchair") // public String wheelchair; // // @SerializedName("wheelchair:description") // public String wheelchairDescription; // // @SerializedName("opening_hours") // public String openingHours; // // @SerializedName("internet_access") // public String internetAccess; // // @SerializedName("fee") // public String fee; // // @SerializedName("operator") // public String operator; // // } // } // } // // Path: library-retrofit-legacy-adapter/src/main/java/hu/supercluster/overpasser/adapter/OverpassQueryResult.java // public static class Element { // @SerializedName("type") // public String type; // // @SerializedName("id") // public long id; // // @SerializedName("lat") // public double lat; // // @SerializedName("lon") // public double lon; // // @SerializedName("tags") // public Tags tags = new Tags(); // // public static class Tags { // @SerializedName("type") // public String type; // // @SerializedName("amenity") // public String amenity; // // @SerializedName("name") // public String name; // // @SerializedName("phone") // public String phone; // // @SerializedName("contact:email") // public String contactEmail; // // @SerializedName("website") // public String website; // // @SerializedName("addr:city") // public String addressCity; // // @SerializedName("addr:postcode") // public String addressPostCode; // // @SerializedName("addr:street") // public String addressStreet; // // @SerializedName("addr:housenumber") // public String addressHouseNumber; // // @SerializedName("wheelchair") // public String wheelchair; // // @SerializedName("wheelchair:description") // public String wheelchairDescription; // // @SerializedName("opening_hours") // public String openingHours; // // @SerializedName("internet_access") // public String internetAccess; // // @SerializedName("fee") // public String fee; // // @SerializedName("operator") // public String operator; // // } // }
import android.content.Context; import android.content.res.Resources; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.model.Marker; import org.androidannotations.annotations.EBean; import org.androidannotations.annotations.RootContext; import java.util.HashMap; import java.util.Map; import hu.supercluster.overpasser.R; import hu.supercluster.overpasser.adapter.OverpassQueryResult; import hu.supercluster.overpasser.adapter.OverpassQueryResult.Element; import hugo.weaving.DebugLog;
package hu.supercluster.overpasser.app.view; @EBean(scope = EBean.Scope.Singleton) public class PoiInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
// Path: library-retrofit-legacy-adapter/src/main/java/hu/supercluster/overpasser/adapter/OverpassQueryResult.java // public class OverpassQueryResult { // @SerializedName("elements") // public List<Element> elements = new ArrayList<>(); // // public static class Element { // @SerializedName("type") // public String type; // // @SerializedName("id") // public long id; // // @SerializedName("lat") // public double lat; // // @SerializedName("lon") // public double lon; // // @SerializedName("tags") // public Tags tags = new Tags(); // // public static class Tags { // @SerializedName("type") // public String type; // // @SerializedName("amenity") // public String amenity; // // @SerializedName("name") // public String name; // // @SerializedName("phone") // public String phone; // // @SerializedName("contact:email") // public String contactEmail; // // @SerializedName("website") // public String website; // // @SerializedName("addr:city") // public String addressCity; // // @SerializedName("addr:postcode") // public String addressPostCode; // // @SerializedName("addr:street") // public String addressStreet; // // @SerializedName("addr:housenumber") // public String addressHouseNumber; // // @SerializedName("wheelchair") // public String wheelchair; // // @SerializedName("wheelchair:description") // public String wheelchairDescription; // // @SerializedName("opening_hours") // public String openingHours; // // @SerializedName("internet_access") // public String internetAccess; // // @SerializedName("fee") // public String fee; // // @SerializedName("operator") // public String operator; // // } // } // } // // Path: library-retrofit-legacy-adapter/src/main/java/hu/supercluster/overpasser/adapter/OverpassQueryResult.java // public static class Element { // @SerializedName("type") // public String type; // // @SerializedName("id") // public long id; // // @SerializedName("lat") // public double lat; // // @SerializedName("lon") // public double lon; // // @SerializedName("tags") // public Tags tags = new Tags(); // // public static class Tags { // @SerializedName("type") // public String type; // // @SerializedName("amenity") // public String amenity; // // @SerializedName("name") // public String name; // // @SerializedName("phone") // public String phone; // // @SerializedName("contact:email") // public String contactEmail; // // @SerializedName("website") // public String website; // // @SerializedName("addr:city") // public String addressCity; // // @SerializedName("addr:postcode") // public String addressPostCode; // // @SerializedName("addr:street") // public String addressStreet; // // @SerializedName("addr:housenumber") // public String addressHouseNumber; // // @SerializedName("wheelchair") // public String wheelchair; // // @SerializedName("wheelchair:description") // public String wheelchairDescription; // // @SerializedName("opening_hours") // public String openingHours; // // @SerializedName("internet_access") // public String internetAccess; // // @SerializedName("fee") // public String fee; // // @SerializedName("operator") // public String operator; // // } // } // Path: sample/src/main/java/hu/supercluster/overpasser/app/view/PoiInfoWindowAdapter.java import android.content.Context; import android.content.res.Resources; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.model.Marker; import org.androidannotations.annotations.EBean; import org.androidannotations.annotations.RootContext; import java.util.HashMap; import java.util.Map; import hu.supercluster.overpasser.R; import hu.supercluster.overpasser.adapter.OverpassQueryResult; import hu.supercluster.overpasser.adapter.OverpassQueryResult.Element; import hugo.weaving.DebugLog; package hu.supercluster.overpasser.app.view; @EBean(scope = EBean.Scope.Singleton) public class PoiInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
private Map<String, OverpassQueryResult.Element> map;
zsoltk/overpasser
sample/src/main/java/hu/supercluster/overpasser/app/view/PoiInfoWindowAdapter.java
// Path: library-retrofit-legacy-adapter/src/main/java/hu/supercluster/overpasser/adapter/OverpassQueryResult.java // public class OverpassQueryResult { // @SerializedName("elements") // public List<Element> elements = new ArrayList<>(); // // public static class Element { // @SerializedName("type") // public String type; // // @SerializedName("id") // public long id; // // @SerializedName("lat") // public double lat; // // @SerializedName("lon") // public double lon; // // @SerializedName("tags") // public Tags tags = new Tags(); // // public static class Tags { // @SerializedName("type") // public String type; // // @SerializedName("amenity") // public String amenity; // // @SerializedName("name") // public String name; // // @SerializedName("phone") // public String phone; // // @SerializedName("contact:email") // public String contactEmail; // // @SerializedName("website") // public String website; // // @SerializedName("addr:city") // public String addressCity; // // @SerializedName("addr:postcode") // public String addressPostCode; // // @SerializedName("addr:street") // public String addressStreet; // // @SerializedName("addr:housenumber") // public String addressHouseNumber; // // @SerializedName("wheelchair") // public String wheelchair; // // @SerializedName("wheelchair:description") // public String wheelchairDescription; // // @SerializedName("opening_hours") // public String openingHours; // // @SerializedName("internet_access") // public String internetAccess; // // @SerializedName("fee") // public String fee; // // @SerializedName("operator") // public String operator; // // } // } // } // // Path: library-retrofit-legacy-adapter/src/main/java/hu/supercluster/overpasser/adapter/OverpassQueryResult.java // public static class Element { // @SerializedName("type") // public String type; // // @SerializedName("id") // public long id; // // @SerializedName("lat") // public double lat; // // @SerializedName("lon") // public double lon; // // @SerializedName("tags") // public Tags tags = new Tags(); // // public static class Tags { // @SerializedName("type") // public String type; // // @SerializedName("amenity") // public String amenity; // // @SerializedName("name") // public String name; // // @SerializedName("phone") // public String phone; // // @SerializedName("contact:email") // public String contactEmail; // // @SerializedName("website") // public String website; // // @SerializedName("addr:city") // public String addressCity; // // @SerializedName("addr:postcode") // public String addressPostCode; // // @SerializedName("addr:street") // public String addressStreet; // // @SerializedName("addr:housenumber") // public String addressHouseNumber; // // @SerializedName("wheelchair") // public String wheelchair; // // @SerializedName("wheelchair:description") // public String wheelchairDescription; // // @SerializedName("opening_hours") // public String openingHours; // // @SerializedName("internet_access") // public String internetAccess; // // @SerializedName("fee") // public String fee; // // @SerializedName("operator") // public String operator; // // } // }
import android.content.Context; import android.content.res.Resources; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.model.Marker; import org.androidannotations.annotations.EBean; import org.androidannotations.annotations.RootContext; import java.util.HashMap; import java.util.Map; import hu.supercluster.overpasser.R; import hu.supercluster.overpasser.adapter.OverpassQueryResult; import hu.supercluster.overpasser.adapter.OverpassQueryResult.Element; import hugo.weaving.DebugLog;
package hu.supercluster.overpasser.app.view; @EBean(scope = EBean.Scope.Singleton) public class PoiInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
// Path: library-retrofit-legacy-adapter/src/main/java/hu/supercluster/overpasser/adapter/OverpassQueryResult.java // public class OverpassQueryResult { // @SerializedName("elements") // public List<Element> elements = new ArrayList<>(); // // public static class Element { // @SerializedName("type") // public String type; // // @SerializedName("id") // public long id; // // @SerializedName("lat") // public double lat; // // @SerializedName("lon") // public double lon; // // @SerializedName("tags") // public Tags tags = new Tags(); // // public static class Tags { // @SerializedName("type") // public String type; // // @SerializedName("amenity") // public String amenity; // // @SerializedName("name") // public String name; // // @SerializedName("phone") // public String phone; // // @SerializedName("contact:email") // public String contactEmail; // // @SerializedName("website") // public String website; // // @SerializedName("addr:city") // public String addressCity; // // @SerializedName("addr:postcode") // public String addressPostCode; // // @SerializedName("addr:street") // public String addressStreet; // // @SerializedName("addr:housenumber") // public String addressHouseNumber; // // @SerializedName("wheelchair") // public String wheelchair; // // @SerializedName("wheelchair:description") // public String wheelchairDescription; // // @SerializedName("opening_hours") // public String openingHours; // // @SerializedName("internet_access") // public String internetAccess; // // @SerializedName("fee") // public String fee; // // @SerializedName("operator") // public String operator; // // } // } // } // // Path: library-retrofit-legacy-adapter/src/main/java/hu/supercluster/overpasser/adapter/OverpassQueryResult.java // public static class Element { // @SerializedName("type") // public String type; // // @SerializedName("id") // public long id; // // @SerializedName("lat") // public double lat; // // @SerializedName("lon") // public double lon; // // @SerializedName("tags") // public Tags tags = new Tags(); // // public static class Tags { // @SerializedName("type") // public String type; // // @SerializedName("amenity") // public String amenity; // // @SerializedName("name") // public String name; // // @SerializedName("phone") // public String phone; // // @SerializedName("contact:email") // public String contactEmail; // // @SerializedName("website") // public String website; // // @SerializedName("addr:city") // public String addressCity; // // @SerializedName("addr:postcode") // public String addressPostCode; // // @SerializedName("addr:street") // public String addressStreet; // // @SerializedName("addr:housenumber") // public String addressHouseNumber; // // @SerializedName("wheelchair") // public String wheelchair; // // @SerializedName("wheelchair:description") // public String wheelchairDescription; // // @SerializedName("opening_hours") // public String openingHours; // // @SerializedName("internet_access") // public String internetAccess; // // @SerializedName("fee") // public String fee; // // @SerializedName("operator") // public String operator; // // } // } // Path: sample/src/main/java/hu/supercluster/overpasser/app/view/PoiInfoWindowAdapter.java import android.content.Context; import android.content.res.Resources; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.model.Marker; import org.androidannotations.annotations.EBean; import org.androidannotations.annotations.RootContext; import java.util.HashMap; import java.util.Map; import hu.supercluster.overpasser.R; import hu.supercluster.overpasser.adapter.OverpassQueryResult; import hu.supercluster.overpasser.adapter.OverpassQueryResult.Element; import hugo.weaving.DebugLog; package hu.supercluster.overpasser.app.view; @EBean(scope = EBean.Scope.Singleton) public class PoiInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
private Map<String, OverpassQueryResult.Element> map;
mvk13ogb/qwait
src/main/java/se/kth/csc/auth/UserService.java
// Path: src/main/java/se/kth/csc/model/Account.java // @Entity // @Table(name = "account") // public class Account { // @Id // @GeneratedValue(strategy = GenerationType.SEQUENCE) // @Column(name = "id", updatable = false) // private int id; // // @Column(name = "principal_name", unique = true) // private String principalName; // // @Column(name = "name") // private String name; // // @Column(name = "admin") // private boolean admin; // // @OneToMany(fetch = FetchType.EAGER, mappedBy = "account", cascade = CascadeType.ALL) // private Set<QueuePosition> positions = Sets.newHashSet(); // // @ManyToMany(fetch = FetchType.EAGER, mappedBy = "owners", cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST}) // private Set<Queue> ownedQueues = Sets.newHashSet(); // // @ManyToMany(fetch = FetchType.EAGER, mappedBy = "moderators", cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST}) // private Set<Queue> moderatedQueues = Sets.newHashSet(); // // public int getId() { // return id; // } // // public String getPrincipalName() { // return principalName; // } // // public void setPrincipalName(String principalName) { // this.principalName = principalName; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public boolean isAdmin() { return admin; } // // public boolean canEditQueue(Queue queue) { // if(isAdmin()) { // return true; // } // return ownedQueues.contains(queue); // } // // public boolean canModerateQueue(Queue queue) { // if(isAdmin()) { // return true; // } // if(ownedQueues.contains(queue)) {return true;} // return moderatedQueues.contains(queue); // } // // public void setAdmin(boolean admin) { // this.admin = admin; // } // // @JsonView(Account.class) // public Set<QueuePosition> getPositions() { // return positions; // } // // public void setPositions(Set<QueuePosition> positions) { // this.positions = Sets.newHashSet(positions); // } // // @JsonView(Account.class) // public Set<Queue> getOwnedQueues() { // return ownedQueues; // } // // @JsonView(Account.class) // public Set<Queue> getModeratedQueues() { // return moderatedQueues; // } // // public void setOwnedQueues(Set<Queue> queues) { // this.ownedQueues = Sets.newHashSet(queues); // } // // public void setModeratedQueues(Set<Queue> queues) { // this.moderatedQueues = Sets.newHashSet(queues); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Account account = (Account) o; // // if (!principalName.equals(account.principalName)) return false; // // return true; // } // // @Override // public int hashCode() { // return principalName.hashCode(); // } // } // // Path: src/main/java/se/kth/csc/persist/AccountStore.java // public interface AccountStore { // public Account fetchAccountWithId(int id); // // public Account fetchAccountWithPrincipalName(String principalName); // // public Account fetchNewestAccount(); // // public void storeAccount(Account account); // // public Iterable<Account> findAccounts(boolean onlyAdmin, String query); // }
import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import se.kth.csc.model.Account; import se.kth.csc.persist.AccountStore; import java.util.Collection; import com.google.common.collect.ImmutableSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.core.CredentialsContainer; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; import org.springframework.security.core.userdetails.UserDetails;
package se.kth.csc.auth; /* * #%L * QWait * %% * Copyright (C) 2013 - 2014 KTH School of Computer Science and Communication * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ @Service public class UserService implements AuthenticationUserDetailsService<Authentication> { private static final Logger log = LoggerFactory.getLogger(UserService.class);
// Path: src/main/java/se/kth/csc/model/Account.java // @Entity // @Table(name = "account") // public class Account { // @Id // @GeneratedValue(strategy = GenerationType.SEQUENCE) // @Column(name = "id", updatable = false) // private int id; // // @Column(name = "principal_name", unique = true) // private String principalName; // // @Column(name = "name") // private String name; // // @Column(name = "admin") // private boolean admin; // // @OneToMany(fetch = FetchType.EAGER, mappedBy = "account", cascade = CascadeType.ALL) // private Set<QueuePosition> positions = Sets.newHashSet(); // // @ManyToMany(fetch = FetchType.EAGER, mappedBy = "owners", cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST}) // private Set<Queue> ownedQueues = Sets.newHashSet(); // // @ManyToMany(fetch = FetchType.EAGER, mappedBy = "moderators", cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST}) // private Set<Queue> moderatedQueues = Sets.newHashSet(); // // public int getId() { // return id; // } // // public String getPrincipalName() { // return principalName; // } // // public void setPrincipalName(String principalName) { // this.principalName = principalName; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public boolean isAdmin() { return admin; } // // public boolean canEditQueue(Queue queue) { // if(isAdmin()) { // return true; // } // return ownedQueues.contains(queue); // } // // public boolean canModerateQueue(Queue queue) { // if(isAdmin()) { // return true; // } // if(ownedQueues.contains(queue)) {return true;} // return moderatedQueues.contains(queue); // } // // public void setAdmin(boolean admin) { // this.admin = admin; // } // // @JsonView(Account.class) // public Set<QueuePosition> getPositions() { // return positions; // } // // public void setPositions(Set<QueuePosition> positions) { // this.positions = Sets.newHashSet(positions); // } // // @JsonView(Account.class) // public Set<Queue> getOwnedQueues() { // return ownedQueues; // } // // @JsonView(Account.class) // public Set<Queue> getModeratedQueues() { // return moderatedQueues; // } // // public void setOwnedQueues(Set<Queue> queues) { // this.ownedQueues = Sets.newHashSet(queues); // } // // public void setModeratedQueues(Set<Queue> queues) { // this.moderatedQueues = Sets.newHashSet(queues); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Account account = (Account) o; // // if (!principalName.equals(account.principalName)) return false; // // return true; // } // // @Override // public int hashCode() { // return principalName.hashCode(); // } // } // // Path: src/main/java/se/kth/csc/persist/AccountStore.java // public interface AccountStore { // public Account fetchAccountWithId(int id); // // public Account fetchAccountWithPrincipalName(String principalName); // // public Account fetchNewestAccount(); // // public void storeAccount(Account account); // // public Iterable<Account> findAccounts(boolean onlyAdmin, String query); // } // Path: src/main/java/se/kth/csc/auth/UserService.java import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import se.kth.csc.model.Account; import se.kth.csc.persist.AccountStore; import java.util.Collection; import com.google.common.collect.ImmutableSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.core.CredentialsContainer; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; import org.springframework.security.core.userdetails.UserDetails; package se.kth.csc.auth; /* * #%L * QWait * %% * Copyright (C) 2013 - 2014 KTH School of Computer Science and Communication * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ @Service public class UserService implements AuthenticationUserDetailsService<Authentication> { private static final Logger log = LoggerFactory.getLogger(UserService.class);
private final AccountStore accountStore;
mvk13ogb/qwait
src/main/java/se/kth/csc/auth/UserService.java
// Path: src/main/java/se/kth/csc/model/Account.java // @Entity // @Table(name = "account") // public class Account { // @Id // @GeneratedValue(strategy = GenerationType.SEQUENCE) // @Column(name = "id", updatable = false) // private int id; // // @Column(name = "principal_name", unique = true) // private String principalName; // // @Column(name = "name") // private String name; // // @Column(name = "admin") // private boolean admin; // // @OneToMany(fetch = FetchType.EAGER, mappedBy = "account", cascade = CascadeType.ALL) // private Set<QueuePosition> positions = Sets.newHashSet(); // // @ManyToMany(fetch = FetchType.EAGER, mappedBy = "owners", cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST}) // private Set<Queue> ownedQueues = Sets.newHashSet(); // // @ManyToMany(fetch = FetchType.EAGER, mappedBy = "moderators", cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST}) // private Set<Queue> moderatedQueues = Sets.newHashSet(); // // public int getId() { // return id; // } // // public String getPrincipalName() { // return principalName; // } // // public void setPrincipalName(String principalName) { // this.principalName = principalName; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public boolean isAdmin() { return admin; } // // public boolean canEditQueue(Queue queue) { // if(isAdmin()) { // return true; // } // return ownedQueues.contains(queue); // } // // public boolean canModerateQueue(Queue queue) { // if(isAdmin()) { // return true; // } // if(ownedQueues.contains(queue)) {return true;} // return moderatedQueues.contains(queue); // } // // public void setAdmin(boolean admin) { // this.admin = admin; // } // // @JsonView(Account.class) // public Set<QueuePosition> getPositions() { // return positions; // } // // public void setPositions(Set<QueuePosition> positions) { // this.positions = Sets.newHashSet(positions); // } // // @JsonView(Account.class) // public Set<Queue> getOwnedQueues() { // return ownedQueues; // } // // @JsonView(Account.class) // public Set<Queue> getModeratedQueues() { // return moderatedQueues; // } // // public void setOwnedQueues(Set<Queue> queues) { // this.ownedQueues = Sets.newHashSet(queues); // } // // public void setModeratedQueues(Set<Queue> queues) { // this.moderatedQueues = Sets.newHashSet(queues); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Account account = (Account) o; // // if (!principalName.equals(account.principalName)) return false; // // return true; // } // // @Override // public int hashCode() { // return principalName.hashCode(); // } // } // // Path: src/main/java/se/kth/csc/persist/AccountStore.java // public interface AccountStore { // public Account fetchAccountWithId(int id); // // public Account fetchAccountWithPrincipalName(String principalName); // // public Account fetchNewestAccount(); // // public void storeAccount(Account account); // // public Iterable<Account> findAccounts(boolean onlyAdmin, String query); // }
import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import se.kth.csc.model.Account; import se.kth.csc.persist.AccountStore; import java.util.Collection; import com.google.common.collect.ImmutableSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.core.CredentialsContainer; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; import org.springframework.security.core.userdetails.UserDetails;
package se.kth.csc.auth; /* * #%L * QWait * %% * Copyright (C) 2013 - 2014 KTH School of Computer Science and Communication * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ @Service public class UserService implements AuthenticationUserDetailsService<Authentication> { private static final Logger log = LoggerFactory.getLogger(UserService.class); private final AccountStore accountStore; private final NameService nameService; @Autowired public UserService(AccountStore accountStore, NameService nameService) { this.accountStore = accountStore; this.nameService = nameService; } @Transactional @Override public UserDetails loadUserDetails(Authentication token) throws UsernameNotFoundException { if (!token.getName().startsWith("u1")) { // See http://intra.kth.se/it/driftsinformation-webbtjanster/anstallda/inloggning-maste-ske-med-sma-bokstaver-1.475521 // which allows an exploit. Counter-measured by only allowing usernames starting with "u1" throw new UsernameNotFoundException("This username is not in the u1 realm and was probably forged"); }
// Path: src/main/java/se/kth/csc/model/Account.java // @Entity // @Table(name = "account") // public class Account { // @Id // @GeneratedValue(strategy = GenerationType.SEQUENCE) // @Column(name = "id", updatable = false) // private int id; // // @Column(name = "principal_name", unique = true) // private String principalName; // // @Column(name = "name") // private String name; // // @Column(name = "admin") // private boolean admin; // // @OneToMany(fetch = FetchType.EAGER, mappedBy = "account", cascade = CascadeType.ALL) // private Set<QueuePosition> positions = Sets.newHashSet(); // // @ManyToMany(fetch = FetchType.EAGER, mappedBy = "owners", cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST}) // private Set<Queue> ownedQueues = Sets.newHashSet(); // // @ManyToMany(fetch = FetchType.EAGER, mappedBy = "moderators", cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST}) // private Set<Queue> moderatedQueues = Sets.newHashSet(); // // public int getId() { // return id; // } // // public String getPrincipalName() { // return principalName; // } // // public void setPrincipalName(String principalName) { // this.principalName = principalName; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public boolean isAdmin() { return admin; } // // public boolean canEditQueue(Queue queue) { // if(isAdmin()) { // return true; // } // return ownedQueues.contains(queue); // } // // public boolean canModerateQueue(Queue queue) { // if(isAdmin()) { // return true; // } // if(ownedQueues.contains(queue)) {return true;} // return moderatedQueues.contains(queue); // } // // public void setAdmin(boolean admin) { // this.admin = admin; // } // // @JsonView(Account.class) // public Set<QueuePosition> getPositions() { // return positions; // } // // public void setPositions(Set<QueuePosition> positions) { // this.positions = Sets.newHashSet(positions); // } // // @JsonView(Account.class) // public Set<Queue> getOwnedQueues() { // return ownedQueues; // } // // @JsonView(Account.class) // public Set<Queue> getModeratedQueues() { // return moderatedQueues; // } // // public void setOwnedQueues(Set<Queue> queues) { // this.ownedQueues = Sets.newHashSet(queues); // } // // public void setModeratedQueues(Set<Queue> queues) { // this.moderatedQueues = Sets.newHashSet(queues); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Account account = (Account) o; // // if (!principalName.equals(account.principalName)) return false; // // return true; // } // // @Override // public int hashCode() { // return principalName.hashCode(); // } // } // // Path: src/main/java/se/kth/csc/persist/AccountStore.java // public interface AccountStore { // public Account fetchAccountWithId(int id); // // public Account fetchAccountWithPrincipalName(String principalName); // // public Account fetchNewestAccount(); // // public void storeAccount(Account account); // // public Iterable<Account> findAccounts(boolean onlyAdmin, String query); // } // Path: src/main/java/se/kth/csc/auth/UserService.java import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import se.kth.csc.model.Account; import se.kth.csc.persist.AccountStore; import java.util.Collection; import com.google.common.collect.ImmutableSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.core.CredentialsContainer; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; import org.springframework.security.core.userdetails.UserDetails; package se.kth.csc.auth; /* * #%L * QWait * %% * Copyright (C) 2013 - 2014 KTH School of Computer Science and Communication * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ @Service public class UserService implements AuthenticationUserDetailsService<Authentication> { private static final Logger log = LoggerFactory.getLogger(UserService.class); private final AccountStore accountStore; private final NameService nameService; @Autowired public UserService(AccountStore accountStore, NameService nameService) { this.accountStore = accountStore; this.nameService = nameService; } @Transactional @Override public UserDetails loadUserDetails(Authentication token) throws UsernameNotFoundException { if (!token.getName().startsWith("u1")) { // See http://intra.kth.se/it/driftsinformation-webbtjanster/anstallda/inloggning-maste-ske-med-sma-bokstaver-1.475521 // which allows an exploit. Counter-measured by only allowing usernames starting with "u1" throw new UsernameNotFoundException("This username is not in the u1 realm and was probably forged"); }
Account account = accountStore.fetchAccountWithPrincipalName(token.getName());
mvk13ogb/qwait
src/main/java/se/kth/csc/config/JpaConfig.java
// Path: src/main/java/se/kth/csc/Application.java // public interface Application { // }
import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.TransactionManagementConfigurer; import se.kth.csc.Application; import javax.sql.DataSource; import java.util.Properties; import org.hibernate.cfg.Environment; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
package se.kth.csc.config; /* * #%L * QWait * %% * Copyright (C) 2013 - 2014 KTH School of Computer Science and Communication * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ /** * Configures JPA to run on top of our data source. */ @Configuration @EnableTransactionManagement
// Path: src/main/java/se/kth/csc/Application.java // public interface Application { // } // Path: src/main/java/se/kth/csc/config/JpaConfig.java import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.TransactionManagementConfigurer; import se.kth.csc.Application; import javax.sql.DataSource; import java.util.Properties; import org.hibernate.cfg.Environment; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; package se.kth.csc.config; /* * #%L * QWait * %% * Copyright (C) 2013 - 2014 KTH School of Computer Science and Communication * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ /** * Configures JPA to run on top of our data source. */ @Configuration @EnableTransactionManagement
@EnableJpaRepositories(basePackageClasses = Application.class)
mvk13ogb/qwait
src/main/java/se/kth/csc/controller/HomeController.java
// Path: src/main/java/se/kth/csc/persist/AccountStore.java // public interface AccountStore { // public Account fetchAccountWithId(int id); // // public Account fetchAccountWithPrincipalName(String principalName); // // public Account fetchNewestAccount(); // // public void storeAccount(Account account); // // public Iterable<Account> findAccounts(boolean onlyAdmin, String query); // }
import org.springframework.web.servlet.ModelAndView; import se.kth.csc.persist.AccountStore; import javax.servlet.http.HttpServletRequest; import java.net.InetAddress; import java.net.UnknownHostException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam;
package se.kth.csc.controller; /* * #%L * QWait * %% * Copyright (C) 2013 - 2014 KTH School of Computer Science and Communication * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ /** * Controls the home page. */ @Controller public class HomeController { private static final Logger log = LoggerFactory.getLogger(HomeController.class);
// Path: src/main/java/se/kth/csc/persist/AccountStore.java // public interface AccountStore { // public Account fetchAccountWithId(int id); // // public Account fetchAccountWithPrincipalName(String principalName); // // public Account fetchNewestAccount(); // // public void storeAccount(Account account); // // public Iterable<Account> findAccounts(boolean onlyAdmin, String query); // } // Path: src/main/java/se/kth/csc/controller/HomeController.java import org.springframework.web.servlet.ModelAndView; import se.kth.csc.persist.AccountStore; import javax.servlet.http.HttpServletRequest; import java.net.InetAddress; import java.net.UnknownHostException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; package se.kth.csc.controller; /* * #%L * QWait * %% * Copyright (C) 2013 - 2014 KTH School of Computer Science and Communication * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ /** * Controls the home page. */ @Controller public class HomeController { private static final Logger log = LoggerFactory.getLogger(HomeController.class);
private final AccountStore accountStore;
mvk13ogb/qwait
src/main/java/se/kth/csc/config/SecurityConfig.java
// Path: src/main/java/se/kth/csc/auth/FilteredCasAuthEntryPoint.java // public class FilteredCasAuthEntryPoint implements AuthenticationEntryPoint, InitializingBean { // // private ServiceProperties serviceProperties; // // private String loginUrl; // // public void afterPropertiesSet() throws Exception { // Assert.hasLength(this.loginUrl, "loginUrl must be specified"); // Assert.notNull(this.serviceProperties, "serviceProperties must be specified"); // } // // public final void commence(final HttpServletRequest servletRequest, final HttpServletResponse response, // final AuthenticationException authenticationException) throws IOException, ServletException { // // final String urlEncodedService = CommonUtils.constructServiceUrl( // null, response, this.serviceProperties.getService(), null, this.serviceProperties.getArtifactParameter(), true); // final String redirectUrl = CommonUtils.constructRedirectUrl( // this.loginUrl, this.serviceProperties.getServiceParameter(), urlEncodedService, this.serviceProperties.isSendRenew(), false); // // String accept = servletRequest.getHeader("Accept"); // if (accept != null && accept.contains("text/html")) { // response.sendRedirect(redirectUrl); // } else { // response.sendError(HttpServletResponse.SC_FORBIDDEN, "Access to this resource requires authentication"); // } // } // // public final String getLoginUrl() { // return this.loginUrl; // } // // public final ServiceProperties getServiceProperties() { // return this.serviceProperties; // } // // public final void setLoginUrl(final String loginUrl) { // this.loginUrl = loginUrl; // } // // public final void setServiceProperties(final ServiceProperties serviceProperties) { // this.serviceProperties = serviceProperties; // } // }
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.cas.ServiceProperties; import org.springframework.security.cas.authentication.CasAuthenticationProvider; import org.springframework.security.cas.web.CasAuthenticationFilter; import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; import org.springframework.security.web.AuthenticationEntryPoint; import se.kth.csc.auth.FilteredCasAuthEntryPoint; import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.Profile;
package se.kth.csc.config; /* * #%L * QWait * %% * Copyright (C) 2013 - 2014 KTH School of Computer Science and Communication * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ @Configuration @ImportResource("classpath:spring-security-context.xml") public class SecurityConfig { private static final Logger log = LoggerFactory.getLogger(SecurityConfig.class); @Bean public ServiceProperties serviceProperties(@Value("${security.cas.service}") String service) { ServiceProperties serviceProperties = new ServiceProperties(); serviceProperties.setService(service); serviceProperties.setSendRenew(false); log.info("Creating CAS service properties with service \"{}\" and no renewal requirement", service); return serviceProperties; } @Autowired @Bean public CasAuthenticationFilter casAuthenticationFilter(AuthenticationManager authenticationManager) { CasAuthenticationFilter casAuthenticationFilter = new CasAuthenticationFilter(); casAuthenticationFilter.setAuthenticationManager(authenticationManager); casAuthenticationFilter.setFilterProcessesUrl("/authenticate"); log.info("Creating CAS authentication filter with process URL \"/authenticate\""); return casAuthenticationFilter; } @Autowired @Bean public AuthenticationEntryPoint casAuthenticationEntryPoint(@Value("${security.cas.loginUrl}") String loginUrl, ServiceProperties serviceProperties) {
// Path: src/main/java/se/kth/csc/auth/FilteredCasAuthEntryPoint.java // public class FilteredCasAuthEntryPoint implements AuthenticationEntryPoint, InitializingBean { // // private ServiceProperties serviceProperties; // // private String loginUrl; // // public void afterPropertiesSet() throws Exception { // Assert.hasLength(this.loginUrl, "loginUrl must be specified"); // Assert.notNull(this.serviceProperties, "serviceProperties must be specified"); // } // // public final void commence(final HttpServletRequest servletRequest, final HttpServletResponse response, // final AuthenticationException authenticationException) throws IOException, ServletException { // // final String urlEncodedService = CommonUtils.constructServiceUrl( // null, response, this.serviceProperties.getService(), null, this.serviceProperties.getArtifactParameter(), true); // final String redirectUrl = CommonUtils.constructRedirectUrl( // this.loginUrl, this.serviceProperties.getServiceParameter(), urlEncodedService, this.serviceProperties.isSendRenew(), false); // // String accept = servletRequest.getHeader("Accept"); // if (accept != null && accept.contains("text/html")) { // response.sendRedirect(redirectUrl); // } else { // response.sendError(HttpServletResponse.SC_FORBIDDEN, "Access to this resource requires authentication"); // } // } // // public final String getLoginUrl() { // return this.loginUrl; // } // // public final ServiceProperties getServiceProperties() { // return this.serviceProperties; // } // // public final void setLoginUrl(final String loginUrl) { // this.loginUrl = loginUrl; // } // // public final void setServiceProperties(final ServiceProperties serviceProperties) { // this.serviceProperties = serviceProperties; // } // } // Path: src/main/java/se/kth/csc/config/SecurityConfig.java import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.cas.ServiceProperties; import org.springframework.security.cas.authentication.CasAuthenticationProvider; import org.springframework.security.cas.web.CasAuthenticationFilter; import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; import org.springframework.security.web.AuthenticationEntryPoint; import se.kth.csc.auth.FilteredCasAuthEntryPoint; import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.Profile; package se.kth.csc.config; /* * #%L * QWait * %% * Copyright (C) 2013 - 2014 KTH School of Computer Science and Communication * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ @Configuration @ImportResource("classpath:spring-security-context.xml") public class SecurityConfig { private static final Logger log = LoggerFactory.getLogger(SecurityConfig.class); @Bean public ServiceProperties serviceProperties(@Value("${security.cas.service}") String service) { ServiceProperties serviceProperties = new ServiceProperties(); serviceProperties.setService(service); serviceProperties.setSendRenew(false); log.info("Creating CAS service properties with service \"{}\" and no renewal requirement", service); return serviceProperties; } @Autowired @Bean public CasAuthenticationFilter casAuthenticationFilter(AuthenticationManager authenticationManager) { CasAuthenticationFilter casAuthenticationFilter = new CasAuthenticationFilter(); casAuthenticationFilter.setAuthenticationManager(authenticationManager); casAuthenticationFilter.setFilterProcessesUrl("/authenticate"); log.info("Creating CAS authentication filter with process URL \"/authenticate\""); return casAuthenticationFilter; } @Autowired @Bean public AuthenticationEntryPoint casAuthenticationEntryPoint(@Value("${security.cas.loginUrl}") String loginUrl, ServiceProperties serviceProperties) {
FilteredCasAuthEntryPoint casAuthenticationEntryPoint = new FilteredCasAuthEntryPoint();
LightSun/Mvcs
Mvcs-java/src/main/java/com/heaven7/java/mvcs/StateGroup.java
// Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/util/MathUtil.java // public static int max2K(int n) { // return (int) Math.pow(2, log2n(n)); // } // // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/IController.java // interface StateFactory<S extends AbstractState<P>, P>{ // // /** // * create state by key and parameter. // * @param stateKey the state key // * @param p the parameter // * @return a new state. // */ // S createState(int stateKey, P p); // } // // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/util/MutexStateException.java // public class MutexStateException extends RuntimeException{ // // private static final long serialVersionUID = 3131615968585009508L; // // public MutexStateException() { // super(); // } // // public MutexStateException(String message, Throwable cause) { // super(message, cause); // } // // public MutexStateException(String message) { // super(message); // } // // public MutexStateException(Throwable cause) { // super(cause); // } // // // }
import static com.heaven7.java.mvcs.util.MathUtil.max2K; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.ArrayList; import java.util.List; import com.heaven7.java.base.anno.IntDef; import com.heaven7.java.base.util.Disposeable; import com.heaven7.java.base.util.SparseArray; import com.heaven7.java.mvcs.IController.StateFactory; import com.heaven7.java.mvcs.util.MutexStateException;
} /** * dispatch state change. * * @param shareFlags * the share flags to reenter. * @param enterFlags * the enter flags to enter * @param exitFlags * the exit flags to exit. */ protected void dispatchStateChange(int shareFlags, int enterFlags, int exitFlags) { // Call the exit method of the existing state if (exitFlags != 0) { exitState(exitFlags); } // Call the entry method of the new state if (enterFlags != 0) { enterState(enterFlags); } // call reenter state if (shareFlags != 0) { reenter(shareFlags); } } private void reenter(int sharFlags) { int maxKey; for (; sharFlags > 0;) {
// Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/util/MathUtil.java // public static int max2K(int n) { // return (int) Math.pow(2, log2n(n)); // } // // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/IController.java // interface StateFactory<S extends AbstractState<P>, P>{ // // /** // * create state by key and parameter. // * @param stateKey the state key // * @param p the parameter // * @return a new state. // */ // S createState(int stateKey, P p); // } // // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/util/MutexStateException.java // public class MutexStateException extends RuntimeException{ // // private static final long serialVersionUID = 3131615968585009508L; // // public MutexStateException() { // super(); // } // // public MutexStateException(String message, Throwable cause) { // super(message, cause); // } // // public MutexStateException(String message) { // super(message); // } // // public MutexStateException(Throwable cause) { // super(cause); // } // // // } // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/StateGroup.java import static com.heaven7.java.mvcs.util.MathUtil.max2K; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.ArrayList; import java.util.List; import com.heaven7.java.base.anno.IntDef; import com.heaven7.java.base.util.Disposeable; import com.heaven7.java.base.util.SparseArray; import com.heaven7.java.mvcs.IController.StateFactory; import com.heaven7.java.mvcs.util.MutexStateException; } /** * dispatch state change. * * @param shareFlags * the share flags to reenter. * @param enterFlags * the enter flags to enter * @param exitFlags * the exit flags to exit. */ protected void dispatchStateChange(int shareFlags, int enterFlags, int exitFlags) { // Call the exit method of the existing state if (exitFlags != 0) { exitState(exitFlags); } // Call the entry method of the new state if (enterFlags != 0) { enterState(enterFlags); } // call reenter state if (shareFlags != 0) { reenter(shareFlags); } } private void reenter(int sharFlags) { int maxKey; for (; sharFlags > 0;) {
maxKey = max2K(sharFlags);
LightSun/Mvcs
Mvcs-java/src/main/java/com/heaven7/java/mvcs/StateGroup.java
// Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/util/MathUtil.java // public static int max2K(int n) { // return (int) Math.pow(2, log2n(n)); // } // // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/IController.java // interface StateFactory<S extends AbstractState<P>, P>{ // // /** // * create state by key and parameter. // * @param stateKey the state key // * @param p the parameter // * @return a new state. // */ // S createState(int stateKey, P p); // } // // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/util/MutexStateException.java // public class MutexStateException extends RuntimeException{ // // private static final long serialVersionUID = 3131615968585009508L; // // public MutexStateException() { // super(); // } // // public MutexStateException(String message, Throwable cause) { // super(message, cause); // } // // public MutexStateException(String message) { // super(message); // } // // public MutexStateException(Throwable cause) { // super(cause); // } // // // }
import static com.heaven7.java.mvcs.util.MathUtil.max2K; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.ArrayList; import java.util.List; import com.heaven7.java.base.anno.IntDef; import com.heaven7.java.base.util.Disposeable; import com.heaven7.java.base.util.SparseArray; import com.heaven7.java.mvcs.IController.StateFactory; import com.heaven7.java.mvcs.util.MutexStateException;
//final IController<S, P> controller = getController(); switch (action) { case ACTION_ENTER: mTeamM.onEnterState(stateFlag, state); break; case ACTION_EXIT: mTeamM.onExitState(stateFlag, state); break; case ACTION_REENTER: mTeamM.onReenterState(stateFlag, state); break; default: System.out.println("StateGroup >>> called dispatchStateCallback(): but action can't be resolved."); break; } } } /** * check mutex state of the target expect states. * * @param expect * the expect states * @throws MutexStateException * if the expect states have multi states and have mutex state. * @since 1.1.2 */
// Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/util/MathUtil.java // public static int max2K(int n) { // return (int) Math.pow(2, log2n(n)); // } // // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/IController.java // interface StateFactory<S extends AbstractState<P>, P>{ // // /** // * create state by key and parameter. // * @param stateKey the state key // * @param p the parameter // * @return a new state. // */ // S createState(int stateKey, P p); // } // // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/util/MutexStateException.java // public class MutexStateException extends RuntimeException{ // // private static final long serialVersionUID = 3131615968585009508L; // // public MutexStateException() { // super(); // } // // public MutexStateException(String message, Throwable cause) { // super(message, cause); // } // // public MutexStateException(String message) { // super(message); // } // // public MutexStateException(Throwable cause) { // super(cause); // } // // // } // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/StateGroup.java import static com.heaven7.java.mvcs.util.MathUtil.max2K; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.ArrayList; import java.util.List; import com.heaven7.java.base.anno.IntDef; import com.heaven7.java.base.util.Disposeable; import com.heaven7.java.base.util.SparseArray; import com.heaven7.java.mvcs.IController.StateFactory; import com.heaven7.java.mvcs.util.MutexStateException; //final IController<S, P> controller = getController(); switch (action) { case ACTION_ENTER: mTeamM.onEnterState(stateFlag, state); break; case ACTION_EXIT: mTeamM.onExitState(stateFlag, state); break; case ACTION_REENTER: mTeamM.onReenterState(stateFlag, state); break; default: System.out.println("StateGroup >>> called dispatchStateCallback(): but action can't be resolved."); break; } } } /** * check mutex state of the target expect states. * * @param expect * the expect states * @throws MutexStateException * if the expect states have multi states and have mutex state. * @since 1.1.2 */
private void checkMutexState(int expect) throws MutexStateException {
LightSun/Mvcs
Mvcs-java/src/test/java/com/heaven7/java/mvcs/test/teamstate/CommonFactory.java
// Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/impl/DefaultState.java // public class DefaultState extends SimpleState<PropertyBundle>{ // // } // // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/impl/DefaultStateFactory.java // public interface DefaultStateFactory extends IController.StateFactory<SimpleState<PropertyBundle>,PropertyBundle>{ // // }
import com.heaven7.java.base.util.PropertyBundle; import com.heaven7.java.mvcs.impl.DefaultState; import com.heaven7.java.mvcs.impl.DefaultStateFactory;
package com.heaven7.java.mvcs.test.teamstate; public class CommonFactory implements DefaultStateFactory { private int teamIndex; public CommonFactory(int teamIndex) { super(); this.teamIndex = teamIndex; } @Override
// Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/impl/DefaultState.java // public class DefaultState extends SimpleState<PropertyBundle>{ // // } // // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/impl/DefaultStateFactory.java // public interface DefaultStateFactory extends IController.StateFactory<SimpleState<PropertyBundle>,PropertyBundle>{ // // } // Path: Mvcs-java/src/test/java/com/heaven7/java/mvcs/test/teamstate/CommonFactory.java import com.heaven7.java.base.util.PropertyBundle; import com.heaven7.java.mvcs.impl.DefaultState; import com.heaven7.java.mvcs.impl.DefaultStateFactory; package com.heaven7.java.mvcs.test.teamstate; public class CommonFactory implements DefaultStateFactory { private int teamIndex; public CommonFactory(int teamIndex) { super(); this.teamIndex = teamIndex; } @Override
public DefaultState createState(int stateKey, PropertyBundle p) {
LightSun/Mvcs
Mvcs-java/src/main/java/com/heaven7/java/mvcs/StateTransaction.java
// Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/util/ResultAction.java // public interface ResultAction<R> { // // // /** // * called on action result. // * @param result the result. // */ // void onActionResult(R result); // }
import com.heaven7.java.mvcs.util.ResultAction;
package com.heaven7.java.mvcs; /** * the state transaction. with support. add,set,remove method for {@linkplain IController}. * * @author heaven7 * @since 1.1.5 * @see IController#addState(int, Object) * @see IController#setState(int, Object) * @see IController#removeState(int, Object) */ public abstract class StateTransaction<P> { /* * the flag of save state parameter */ //public static final int FLAG_SAVE_STATE_PARAM = 1; /** * @since 1.2.1 */ public static final byte COMPARE_TYPE_HAS = 1; /** * @since 1.2.1 */ public static final byte COMPARE_TYPE_EQUALS = 2; /** * @since 1.2.1 */ public static final byte APPLY_TYPE_ADD = 3; /** * @since 1.2.1 */ public static final byte APPLY_TYPE_REMOVE = 4; /** * @since 1.2.1 */ public static final byte APPLY_TYPE_SET = 5; /** the states to operate */ /* private */ int mOperateStates = -1; /** add, set, or remove. */ byte mOp; P mParam; /** the compare type * @since 1.2.1 */ byte mCompareType; /** the compare states * @since 1.2.1 */ int mCompareState; /* * the extra flags */ //int mFlags; private Runnable mStart;
// Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/util/ResultAction.java // public interface ResultAction<R> { // // // /** // * called on action result. // * @param result the result. // */ // void onActionResult(R result); // } // Path: Mvcs-java/src/main/java/com/heaven7/java/mvcs/StateTransaction.java import com.heaven7.java.mvcs.util.ResultAction; package com.heaven7.java.mvcs; /** * the state transaction. with support. add,set,remove method for {@linkplain IController}. * * @author heaven7 * @since 1.1.5 * @see IController#addState(int, Object) * @see IController#setState(int, Object) * @see IController#removeState(int, Object) */ public abstract class StateTransaction<P> { /* * the flag of save state parameter */ //public static final int FLAG_SAVE_STATE_PARAM = 1; /** * @since 1.2.1 */ public static final byte COMPARE_TYPE_HAS = 1; /** * @since 1.2.1 */ public static final byte COMPARE_TYPE_EQUALS = 2; /** * @since 1.2.1 */ public static final byte APPLY_TYPE_ADD = 3; /** * @since 1.2.1 */ public static final byte APPLY_TYPE_REMOVE = 4; /** * @since 1.2.1 */ public static final byte APPLY_TYPE_SET = 5; /** the states to operate */ /* private */ int mOperateStates = -1; /** add, set, or remove. */ byte mOp; P mParam; /** the compare type * @since 1.2.1 */ byte mCompareType; /** the compare states * @since 1.2.1 */ int mCompareState; /* * the extra flags */ //int mFlags; private Runnable mStart;
private ResultAction<Boolean> mEnd;
dgomezferro/pasc-paxos
src/main/java/com/yahoo/pasc/paxos/client/ClientState.java
// Path: src/main/java/com/yahoo/pasc/paxos/messages/Hello.java // public class Hello extends PaxosMessage implements Serializable, CloneableDeep<Hello>, EqualsDeep<Hello> { // // private static final long serialVersionUID = -3781061394615967506L; // // int clientId; // // public Hello() { // } // // public Hello(int clientId) { // this.clientId = clientId; // } // // public int getClientId() { // return clientId; // } // // public void setClientId(int clientId) { // this.clientId = clientId; // } // // @Override // public String toString() { // return String.format("{Hello sent from %d %s}", clientId, super.toString()); // } // // public Hello cloneDeep() { // return new Hello(this.clientId); // } // // public boolean equalsDeep(Hello other) { // return this.clientId == other.clientId; // } // } // // Path: src/main/java/com/yahoo/pasc/paxos/messages/Request.java // public class Request extends PaxosMessage implements Serializable, EqualsDeep<Request>, CloneableDeep<Request> { // // private static final long serialVersionUID = 1111659280353033430L; // // int clientId; // long timestamp; // byte[] request; // // public Request() { // } // // public Request(int clientId, long timestamp, byte[] request) { // super(); // this.clientId = clientId; // this.timestamp = timestamp; // this.request = request; // } // // public int getClientId() { // return clientId; // } // // public void setClientId(int clientId) { // this.clientId = clientId; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // // public byte[] getRequest() { // return request; // } // // public void setRequest(byte[] request) { // this.request = request; // } // // @Override // public String toString() { // String requestStr = Arrays.toString(request); // if (requestStr.length() > 20) { // requestStr = requestStr.substring(0, 20) + " ... ]"; // } // return String.format("{Request %s sent from %d at %d %s}", requestStr, clientId, timestamp, super.toString()); // } // // public Request cloneDeep (){ // byte [] resArray = new byte[this.request.length]; // System.arraycopy(request, 0, resArray, 0, request.length); // return new Request(this.clientId, this.timestamp, resArray); // } // // public boolean equalsDeep(Request other){ // if (!Arrays.equals(other.request, this.request)) { // return false; // } // return (this.clientId == other.clientId && this.timestamp == other.timestamp); // } // }
import java.util.BitSet; import com.yahoo.pasc.ProcessState; import com.yahoo.pasc.paxos.messages.Hello; import com.yahoo.pasc.paxos.messages.Request;
/** * Copyright (c) 2011 Yahoo! Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. See accompanying LICENSE file. */ package com.yahoo.pasc.paxos.client; public class ClientState implements ProcessState { int clientId; int servers; int quorum; int connected; int disconnected; int inlineThreshold; TimestampMessage asyncMessages []; long timestamp = -1;
// Path: src/main/java/com/yahoo/pasc/paxos/messages/Hello.java // public class Hello extends PaxosMessage implements Serializable, CloneableDeep<Hello>, EqualsDeep<Hello> { // // private static final long serialVersionUID = -3781061394615967506L; // // int clientId; // // public Hello() { // } // // public Hello(int clientId) { // this.clientId = clientId; // } // // public int getClientId() { // return clientId; // } // // public void setClientId(int clientId) { // this.clientId = clientId; // } // // @Override // public String toString() { // return String.format("{Hello sent from %d %s}", clientId, super.toString()); // } // // public Hello cloneDeep() { // return new Hello(this.clientId); // } // // public boolean equalsDeep(Hello other) { // return this.clientId == other.clientId; // } // } // // Path: src/main/java/com/yahoo/pasc/paxos/messages/Request.java // public class Request extends PaxosMessage implements Serializable, EqualsDeep<Request>, CloneableDeep<Request> { // // private static final long serialVersionUID = 1111659280353033430L; // // int clientId; // long timestamp; // byte[] request; // // public Request() { // } // // public Request(int clientId, long timestamp, byte[] request) { // super(); // this.clientId = clientId; // this.timestamp = timestamp; // this.request = request; // } // // public int getClientId() { // return clientId; // } // // public void setClientId(int clientId) { // this.clientId = clientId; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // // public byte[] getRequest() { // return request; // } // // public void setRequest(byte[] request) { // this.request = request; // } // // @Override // public String toString() { // String requestStr = Arrays.toString(request); // if (requestStr.length() > 20) { // requestStr = requestStr.substring(0, 20) + " ... ]"; // } // return String.format("{Request %s sent from %d at %d %s}", requestStr, clientId, timestamp, super.toString()); // } // // public Request cloneDeep (){ // byte [] resArray = new byte[this.request.length]; // System.arraycopy(request, 0, resArray, 0, request.length); // return new Request(this.clientId, this.timestamp, resArray); // } // // public boolean equalsDeep(Request other){ // if (!Arrays.equals(other.request, this.request)) { // return false; // } // return (this.clientId == other.clientId && this.timestamp == other.timestamp); // } // } // Path: src/main/java/com/yahoo/pasc/paxos/client/ClientState.java import java.util.BitSet; import com.yahoo.pasc.ProcessState; import com.yahoo.pasc.paxos.messages.Hello; import com.yahoo.pasc.paxos.messages.Request; /** * Copyright (c) 2011 Yahoo! Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. See accompanying LICENSE file. */ package com.yahoo.pasc.paxos.client; public class ClientState implements ProcessState { int clientId; int servers; int quorum; int connected; int disconnected; int inlineThreshold; TimestampMessage asyncMessages []; long timestamp = -1;
Request pendingRequest;
dgomezferro/pasc-paxos
src/main/java/com/yahoo/pasc/paxos/client/ClientState.java
// Path: src/main/java/com/yahoo/pasc/paxos/messages/Hello.java // public class Hello extends PaxosMessage implements Serializable, CloneableDeep<Hello>, EqualsDeep<Hello> { // // private static final long serialVersionUID = -3781061394615967506L; // // int clientId; // // public Hello() { // } // // public Hello(int clientId) { // this.clientId = clientId; // } // // public int getClientId() { // return clientId; // } // // public void setClientId(int clientId) { // this.clientId = clientId; // } // // @Override // public String toString() { // return String.format("{Hello sent from %d %s}", clientId, super.toString()); // } // // public Hello cloneDeep() { // return new Hello(this.clientId); // } // // public boolean equalsDeep(Hello other) { // return this.clientId == other.clientId; // } // } // // Path: src/main/java/com/yahoo/pasc/paxos/messages/Request.java // public class Request extends PaxosMessage implements Serializable, EqualsDeep<Request>, CloneableDeep<Request> { // // private static final long serialVersionUID = 1111659280353033430L; // // int clientId; // long timestamp; // byte[] request; // // public Request() { // } // // public Request(int clientId, long timestamp, byte[] request) { // super(); // this.clientId = clientId; // this.timestamp = timestamp; // this.request = request; // } // // public int getClientId() { // return clientId; // } // // public void setClientId(int clientId) { // this.clientId = clientId; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // // public byte[] getRequest() { // return request; // } // // public void setRequest(byte[] request) { // this.request = request; // } // // @Override // public String toString() { // String requestStr = Arrays.toString(request); // if (requestStr.length() > 20) { // requestStr = requestStr.substring(0, 20) + " ... ]"; // } // return String.format("{Request %s sent from %d at %d %s}", requestStr, clientId, timestamp, super.toString()); // } // // public Request cloneDeep (){ // byte [] resArray = new byte[this.request.length]; // System.arraycopy(request, 0, resArray, 0, request.length); // return new Request(this.clientId, this.timestamp, resArray); // } // // public boolean equalsDeep(Request other){ // if (!Arrays.equals(other.request, this.request)) { // return false; // } // return (this.clientId == other.clientId && this.timestamp == other.timestamp); // } // }
import java.util.BitSet; import com.yahoo.pasc.ProcessState; import com.yahoo.pasc.paxos.messages.Hello; import com.yahoo.pasc.paxos.messages.Request;
/** * Copyright (c) 2011 Yahoo! Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. See accompanying LICENSE file. */ package com.yahoo.pasc.paxos.client; public class ClientState implements ProcessState { int clientId; int servers; int quorum; int connected; int disconnected; int inlineThreshold; TimestampMessage asyncMessages []; long timestamp = -1; Request pendingRequest;
// Path: src/main/java/com/yahoo/pasc/paxos/messages/Hello.java // public class Hello extends PaxosMessage implements Serializable, CloneableDeep<Hello>, EqualsDeep<Hello> { // // private static final long serialVersionUID = -3781061394615967506L; // // int clientId; // // public Hello() { // } // // public Hello(int clientId) { // this.clientId = clientId; // } // // public int getClientId() { // return clientId; // } // // public void setClientId(int clientId) { // this.clientId = clientId; // } // // @Override // public String toString() { // return String.format("{Hello sent from %d %s}", clientId, super.toString()); // } // // public Hello cloneDeep() { // return new Hello(this.clientId); // } // // public boolean equalsDeep(Hello other) { // return this.clientId == other.clientId; // } // } // // Path: src/main/java/com/yahoo/pasc/paxos/messages/Request.java // public class Request extends PaxosMessage implements Serializable, EqualsDeep<Request>, CloneableDeep<Request> { // // private static final long serialVersionUID = 1111659280353033430L; // // int clientId; // long timestamp; // byte[] request; // // public Request() { // } // // public Request(int clientId, long timestamp, byte[] request) { // super(); // this.clientId = clientId; // this.timestamp = timestamp; // this.request = request; // } // // public int getClientId() { // return clientId; // } // // public void setClientId(int clientId) { // this.clientId = clientId; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // // public byte[] getRequest() { // return request; // } // // public void setRequest(byte[] request) { // this.request = request; // } // // @Override // public String toString() { // String requestStr = Arrays.toString(request); // if (requestStr.length() > 20) { // requestStr = requestStr.substring(0, 20) + " ... ]"; // } // return String.format("{Request %s sent from %d at %d %s}", requestStr, clientId, timestamp, super.toString()); // } // // public Request cloneDeep (){ // byte [] resArray = new byte[this.request.length]; // System.arraycopy(request, 0, resArray, 0, request.length); // return new Request(this.clientId, this.timestamp, resArray); // } // // public boolean equalsDeep(Request other){ // if (!Arrays.equals(other.request, this.request)) { // return false; // } // return (this.clientId == other.clientId && this.timestamp == other.timestamp); // } // } // Path: src/main/java/com/yahoo/pasc/paxos/client/ClientState.java import java.util.BitSet; import com.yahoo.pasc.ProcessState; import com.yahoo.pasc.paxos.messages.Hello; import com.yahoo.pasc.paxos.messages.Request; /** * Copyright (c) 2011 Yahoo! Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. See accompanying LICENSE file. */ package com.yahoo.pasc.paxos.client; public class ClientState implements ProcessState { int clientId; int servers; int quorum; int connected; int disconnected; int inlineThreshold; TimestampMessage asyncMessages []; long timestamp = -1; Request pendingRequest;
Hello pendingHello;
dgomezferro/pasc-paxos
src/main/java/com/yahoo/pasc/paxos/statemachine/Response.java
// Path: src/main/java/com/yahoo/pasc/paxos/messages/AsyncMessage.java // public class AsyncMessage extends PaxosMessage implements CloneableDeep<AsyncMessage>, EqualsDeep<AsyncMessage> { // private static final long serialVersionUID = -8514053535510009861L; // // private int clientId; // private int serverId; // private long timestamp; // private byte[] message; // // public AsyncMessage(int clientId, int serverId, long timestamp, byte[] message) { // super(); // this.clientId = clientId; // this.serverId = serverId; // this.timestamp = timestamp; // this.message = message; // } // // public int getClientId() { // return clientId; // } // // public void setClientId(int clientId) { // this.clientId = clientId; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // // public int getServerId() { // return serverId; // } // // public void setServerId(int serverId) { // this.serverId = serverId; // } // // public byte[] getMessage() { // return message; // } // // public void setMessage(byte[] message) { // this.message = message; // } // // @Override // public AsyncMessage cloneDeep() { // byte[] msgArray = new byte[this.message.length]; // System.arraycopy(this.message, 0, msgArray, 0, msgArray.length); // return new AsyncMessage(this.clientId, this.serverId, this.timestamp, msgArray); // } // // @Override // public boolean equalsDeep(AsyncMessage other) { // if (!Arrays.equals(other.message, this.message)) { // return false; // } // return (this.clientId == other.clientId && this.serverId == other.serverId && this.timestamp == other.timestamp); // } // // @Override // public String toString() { // return "AsyncMessage [clientId=" + clientId + ", serverId=" + serverId + ", timestamp=" + timestamp // + ", message=" + Arrays.toString(message) + "]"; // } // // }
import java.util.ArrayList; import java.util.List; import com.yahoo.pasc.paxos.messages.AsyncMessage;
package com.yahoo.pasc.paxos.statemachine; public class Response { private byte[] response;
// Path: src/main/java/com/yahoo/pasc/paxos/messages/AsyncMessage.java // public class AsyncMessage extends PaxosMessage implements CloneableDeep<AsyncMessage>, EqualsDeep<AsyncMessage> { // private static final long serialVersionUID = -8514053535510009861L; // // private int clientId; // private int serverId; // private long timestamp; // private byte[] message; // // public AsyncMessage(int clientId, int serverId, long timestamp, byte[] message) { // super(); // this.clientId = clientId; // this.serverId = serverId; // this.timestamp = timestamp; // this.message = message; // } // // public int getClientId() { // return clientId; // } // // public void setClientId(int clientId) { // this.clientId = clientId; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // // public int getServerId() { // return serverId; // } // // public void setServerId(int serverId) { // this.serverId = serverId; // } // // public byte[] getMessage() { // return message; // } // // public void setMessage(byte[] message) { // this.message = message; // } // // @Override // public AsyncMessage cloneDeep() { // byte[] msgArray = new byte[this.message.length]; // System.arraycopy(this.message, 0, msgArray, 0, msgArray.length); // return new AsyncMessage(this.clientId, this.serverId, this.timestamp, msgArray); // } // // @Override // public boolean equalsDeep(AsyncMessage other) { // if (!Arrays.equals(other.message, this.message)) { // return false; // } // return (this.clientId == other.clientId && this.serverId == other.serverId && this.timestamp == other.timestamp); // } // // @Override // public String toString() { // return "AsyncMessage [clientId=" + clientId + ", serverId=" + serverId + ", timestamp=" + timestamp // + ", message=" + Arrays.toString(message) + "]"; // } // // } // Path: src/main/java/com/yahoo/pasc/paxos/statemachine/Response.java import java.util.ArrayList; import java.util.List; import com.yahoo.pasc.paxos.messages.AsyncMessage; package com.yahoo.pasc.paxos.statemachine; public class Response { private byte[] response;
private List<AsyncMessage> asyncMessages;
MaterialPrime/material-prime
src/main/java/org/primefaces/material/component/button/ButtonRenderer.java
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // }
import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import org.primefaces.component.commandbutton.CommandButtonRenderer; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.material.util.Strings; import org.primefaces.util.HTML; import org.primefaces.util.WidgetBuilder;
package org.primefaces.material.component.button; public class ButtonRenderer extends CommandButtonRenderer{ public static final String RENDERER_TYPE = "org.primefaces.material.component.ButtonRenderer"; @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { Button button = (Button) component; encodeMarkup(context, button); encodeScript(context, button); } protected void encodeScript(FacesContext context, Button button) throws IOException { String clientId = button.getClientId(); String widgetVar = button.resolveWidgetVar();
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // } // Path: src/main/java/org/primefaces/material/component/button/ButtonRenderer.java import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import org.primefaces.component.commandbutton.CommandButtonRenderer; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.material.util.Strings; import org.primefaces.util.HTML; import org.primefaces.util.WidgetBuilder; package org.primefaces.material.component.button; public class ButtonRenderer extends CommandButtonRenderer{ public static final String RENDERER_TYPE = "org.primefaces.material.component.ButtonRenderer"; @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { Button button = (Button) component; encodeMarkup(context, button); encodeScript(context, button); } protected void encodeScript(FacesContext context, Button button) throws IOException { String clientId = button.getClientId(); String widgetVar = button.resolveWidgetVar();
WidgetBuilder wb = MaterialWidgetBuilder.getInstance(context);
MaterialPrime/material-prime
src/main/java/org/primefaces/material/component/fixedactionbutton/FixedActionButtonRenderer.java
// Path: src/main/java/org/primefaces/material/MaterialColors.java // public enum MaterialColors { // RED("red"), // PINK("pink"), // PURPLE("purple"), // DEEP_PURPLE("deep-purple"), // INDIGO("indigo"), // BLUE("blue"), // LIGHT_BLUE("light-blue"), // CYAN("cyan"), // TEAL("teal"), // GREEN("green"), // LIGHT_GREEN("light-green"), // LIME("lime"), // YELLOW("yellow"), // AMBER("amber"), // ORANGE("orange"), // DEEP_ORANGE("deep-orange"), // BROWN("brown"), // GREY("grey"), // BLUE_GREY("blue-grey"); // // // private String colorName; // private static Random random = new Random(); // // private MaterialColors(String name){ // this.colorName = name; // } // // public String getColorName(){ // return this.colorName; // } // // public static MaterialColors random(){ // return MaterialColors.values()[random.nextInt(MaterialColors.values().length)]; // } // // } // // Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // }
import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.event.ActionEvent; import org.primefaces.material.MaterialColors; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.material.util.Strings; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder;
package org.primefaces.material.component.fixedactionbutton; public class FixedActionButtonRenderer extends CoreRenderer{ private static final String DEFAULT_FIXED_ACTION_COLOR = "red"; private static final String FIXED_ACTION_BTN_CLASS = "fixed-action-btn"; public static final String RENDERER_TYPE = "org.primefaces.material.component.FixedActionButtonRenderer"; @Override public void decode(FacesContext context, UIComponent fab) { for (UIComponent component : fab.getChildren()) { String param = component.getClientId(context); if(context.getExternalContext().getRequestParameterMap().containsKey(param)) { component.queueEvent(new ActionEvent(component)); } } decodeBehaviors(context, fab); } @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { FixedActionButton button = (FixedActionButton) component; encodeMarkup(context, button); encodeScript(context, button); } protected void encodeScript(FacesContext context, FixedActionButton button) throws IOException { String clientId = button.getClientId(); String widgetVar = button.resolveWidgetVar();
// Path: src/main/java/org/primefaces/material/MaterialColors.java // public enum MaterialColors { // RED("red"), // PINK("pink"), // PURPLE("purple"), // DEEP_PURPLE("deep-purple"), // INDIGO("indigo"), // BLUE("blue"), // LIGHT_BLUE("light-blue"), // CYAN("cyan"), // TEAL("teal"), // GREEN("green"), // LIGHT_GREEN("light-green"), // LIME("lime"), // YELLOW("yellow"), // AMBER("amber"), // ORANGE("orange"), // DEEP_ORANGE("deep-orange"), // BROWN("brown"), // GREY("grey"), // BLUE_GREY("blue-grey"); // // // private String colorName; // private static Random random = new Random(); // // private MaterialColors(String name){ // this.colorName = name; // } // // public String getColorName(){ // return this.colorName; // } // // public static MaterialColors random(){ // return MaterialColors.values()[random.nextInt(MaterialColors.values().length)]; // } // // } // // Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // } // Path: src/main/java/org/primefaces/material/component/fixedactionbutton/FixedActionButtonRenderer.java import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.event.ActionEvent; import org.primefaces.material.MaterialColors; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.material.util.Strings; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder; package org.primefaces.material.component.fixedactionbutton; public class FixedActionButtonRenderer extends CoreRenderer{ private static final String DEFAULT_FIXED_ACTION_COLOR = "red"; private static final String FIXED_ACTION_BTN_CLASS = "fixed-action-btn"; public static final String RENDERER_TYPE = "org.primefaces.material.component.FixedActionButtonRenderer"; @Override public void decode(FacesContext context, UIComponent fab) { for (UIComponent component : fab.getChildren()) { String param = component.getClientId(context); if(context.getExternalContext().getRequestParameterMap().containsKey(param)) { component.queueEvent(new ActionEvent(component)); } } decodeBehaviors(context, fab); } @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { FixedActionButton button = (FixedActionButton) component; encodeMarkup(context, button); encodeScript(context, button); } protected void encodeScript(FacesContext context, FixedActionButton button) throws IOException { String clientId = button.getClientId(); String widgetVar = button.resolveWidgetVar();
WidgetBuilder wb = MaterialWidgetBuilder.getInstance(context);
MaterialPrime/material-prime
src/main/java/org/primefaces/material/component/fixedactionbutton/FixedActionButtonRenderer.java
// Path: src/main/java/org/primefaces/material/MaterialColors.java // public enum MaterialColors { // RED("red"), // PINK("pink"), // PURPLE("purple"), // DEEP_PURPLE("deep-purple"), // INDIGO("indigo"), // BLUE("blue"), // LIGHT_BLUE("light-blue"), // CYAN("cyan"), // TEAL("teal"), // GREEN("green"), // LIGHT_GREEN("light-green"), // LIME("lime"), // YELLOW("yellow"), // AMBER("amber"), // ORANGE("orange"), // DEEP_ORANGE("deep-orange"), // BROWN("brown"), // GREY("grey"), // BLUE_GREY("blue-grey"); // // // private String colorName; // private static Random random = new Random(); // // private MaterialColors(String name){ // this.colorName = name; // } // // public String getColorName(){ // return this.colorName; // } // // public static MaterialColors random(){ // return MaterialColors.values()[random.nextInt(MaterialColors.values().length)]; // } // // } // // Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // }
import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.event.ActionEvent; import org.primefaces.material.MaterialColors; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.material.util.Strings; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder;
if(fab.isHorizontal()){ toReturn += " horizontal"; } if(fab.isClickToToggle()){ toReturn += " click-to-toggle"; } return toReturn; } private void renderFabItem(FacesContext context, ResponseWriter writer, FixedActionButtonItem child) throws IOException { String request = buildAjaxRequest(context, child, null); String onclick = buildDomEvent(context, child, "onclick", "click", "action", request); writer.startElement("li", child); writer.startElement("a", null); writer.writeAttribute("id", child.getClientId(), null); writer.writeAttribute("onclick", onclick, "onclick"); writer.writeAttribute("class", "btn-floating " + getItemColor(child), null); writer.startElement("i", null); writer.writeAttribute("class", child.getIcon(), null); writer.endElement("i"); writer.endElement("a"); writer.endElement("li"); } private String getButtonColor(FacesContext context, FixedActionButton fab) { if(fab.getColor() != null){
// Path: src/main/java/org/primefaces/material/MaterialColors.java // public enum MaterialColors { // RED("red"), // PINK("pink"), // PURPLE("purple"), // DEEP_PURPLE("deep-purple"), // INDIGO("indigo"), // BLUE("blue"), // LIGHT_BLUE("light-blue"), // CYAN("cyan"), // TEAL("teal"), // GREEN("green"), // LIGHT_GREEN("light-green"), // LIME("lime"), // YELLOW("yellow"), // AMBER("amber"), // ORANGE("orange"), // DEEP_ORANGE("deep-orange"), // BROWN("brown"), // GREY("grey"), // BLUE_GREY("blue-grey"); // // // private String colorName; // private static Random random = new Random(); // // private MaterialColors(String name){ // this.colorName = name; // } // // public String getColorName(){ // return this.colorName; // } // // public static MaterialColors random(){ // return MaterialColors.values()[random.nextInt(MaterialColors.values().length)]; // } // // } // // Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // } // Path: src/main/java/org/primefaces/material/component/fixedactionbutton/FixedActionButtonRenderer.java import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.event.ActionEvent; import org.primefaces.material.MaterialColors; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.material.util.Strings; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder; if(fab.isHorizontal()){ toReturn += " horizontal"; } if(fab.isClickToToggle()){ toReturn += " click-to-toggle"; } return toReturn; } private void renderFabItem(FacesContext context, ResponseWriter writer, FixedActionButtonItem child) throws IOException { String request = buildAjaxRequest(context, child, null); String onclick = buildDomEvent(context, child, "onclick", "click", "action", request); writer.startElement("li", child); writer.startElement("a", null); writer.writeAttribute("id", child.getClientId(), null); writer.writeAttribute("onclick", onclick, "onclick"); writer.writeAttribute("class", "btn-floating " + getItemColor(child), null); writer.startElement("i", null); writer.writeAttribute("class", child.getIcon(), null); writer.endElement("i"); writer.endElement("a"); writer.endElement("li"); } private String getButtonColor(FacesContext context, FixedActionButton fab) { if(fab.getColor() != null){
if(fab.getColor() instanceof MaterialColors){
MaterialPrime/material-prime
src/main/java/org/primefaces/material/component/chips/ChipsRenderer.java
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // }
import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.material.util.Strings; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder;
package org.primefaces.material.component.chips; public class ChipsRenderer extends CoreRenderer{ public static final String RENDERER_TYPE = "org.primefaces.material.component.ChipsRenderer"; @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { Chips chips = (Chips) component; encodeMarkup(context, chips); encodeScript(context, chips); } private void encodeScript(FacesContext context, Chips chips) throws IOException { String clientId = chips.getClientId(); String widgetVar = chips.resolveWidgetVar();
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // } // Path: src/main/java/org/primefaces/material/component/chips/ChipsRenderer.java import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.material.util.Strings; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder; package org.primefaces.material.component.chips; public class ChipsRenderer extends CoreRenderer{ public static final String RENDERER_TYPE = "org.primefaces.material.component.ChipsRenderer"; @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { Chips chips = (Chips) component; encodeMarkup(context, chips); encodeScript(context, chips); } private void encodeScript(FacesContext context, Chips chips) throws IOException { String clientId = chips.getClientId(); String widgetVar = chips.resolveWidgetVar();
WidgetBuilder wb = MaterialWidgetBuilder.getInstance(context);
MaterialPrime/material-prime
src/main/java/org/primefaces/material/component/fixedactionbutton/FixedActionButton.java
// Path: src/main/java/org/primefaces/material/component/fixedactionbutton/FixedActionButtonItem.java // protected enum PropertyKeys { // color, // icon, // oncomplete, // onerror, // onsuccess, // onstart, // global, // process, // update, // resetValues, // ignoreAutoUpdate, // partialSubmit, // delay, // timeout, // partialSubmitFilter, // async, // form; // }
import javax.faces.application.ResourceDependencies; import javax.faces.application.ResourceDependency; import javax.faces.component.UINamingContainer; import javax.faces.component.UIPanel; import javax.faces.context.FacesContext; import org.primefaces.component.api.Widget; import org.primefaces.material.MaterialPrime; import org.primefaces.material.component.fixedactionbutton.FixedActionButtonItem.PropertyKeys; import org.primefaces.material.util.Strings;
package org.primefaces.material.component.fixedactionbutton; @ResourceDependencies({ @ResourceDependency(library = "primefaces", name = "jquery/jquery.js"), @ResourceDependency(library = "primefaces", name = "core.js"), @ResourceDependency(library = "material-prime", name = "libs/materialize.css"), @ResourceDependency(library = "material-prime", name = "libs/materialize.js"), @ResourceDependency(library = "material-prime", name = "core/material-prime.js"), @ResourceDependency(library = "material-prime", name = "core/material-prime.css"), @ResourceDependency(library = "material-prime", name = "fixedactionbutton/fixedactionbutton.js") }) public class FixedActionButton extends UIPanel implements Widget { public static final String COMPONENT_TYPE = "org.primefaces.material.component.FixedActionButton"; public FixedActionButton() { setRendererType(FixedActionButtonRenderer.RENDERER_TYPE); }
// Path: src/main/java/org/primefaces/material/component/fixedactionbutton/FixedActionButtonItem.java // protected enum PropertyKeys { // color, // icon, // oncomplete, // onerror, // onsuccess, // onstart, // global, // process, // update, // resetValues, // ignoreAutoUpdate, // partialSubmit, // delay, // timeout, // partialSubmitFilter, // async, // form; // } // Path: src/main/java/org/primefaces/material/component/fixedactionbutton/FixedActionButton.java import javax.faces.application.ResourceDependencies; import javax.faces.application.ResourceDependency; import javax.faces.component.UINamingContainer; import javax.faces.component.UIPanel; import javax.faces.context.FacesContext; import org.primefaces.component.api.Widget; import org.primefaces.material.MaterialPrime; import org.primefaces.material.component.fixedactionbutton.FixedActionButtonItem.PropertyKeys; import org.primefaces.material.util.Strings; package org.primefaces.material.component.fixedactionbutton; @ResourceDependencies({ @ResourceDependency(library = "primefaces", name = "jquery/jquery.js"), @ResourceDependency(library = "primefaces", name = "core.js"), @ResourceDependency(library = "material-prime", name = "libs/materialize.css"), @ResourceDependency(library = "material-prime", name = "libs/materialize.js"), @ResourceDependency(library = "material-prime", name = "core/material-prime.js"), @ResourceDependency(library = "material-prime", name = "core/material-prime.css"), @ResourceDependency(library = "material-prime", name = "fixedactionbutton/fixedactionbutton.js") }) public class FixedActionButton extends UIPanel implements Widget { public static final String COMPONENT_TYPE = "org.primefaces.material.component.FixedActionButton"; public FixedActionButton() { setRendererType(FixedActionButtonRenderer.RENDERER_TYPE); }
protected enum PropertyKeys {
MaterialPrime/material-prime
src/main/java/org/primefaces/material/component/toggle/ToggleRenderer.java
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // }
import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.convert.ConverterException; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.ComponentUtils; import org.primefaces.util.WidgetBuilder;
writer.startElement("div", toggle); writer.writeAttribute("id", toggle.getClientId(), null); writer.writeAttribute("class", "switch", null); writer.startElement("label", null); writer.startElement("input", null); writer.writeAttribute("id", inputId, null); writer.writeAttribute("name", inputId, null); if(toggle.getTabindex() != null){ writer.writeAttribute("tabindex", toggle.getTabindex(), null); } if(toggle.isDisabled()){ writer.writeAttribute("disabled", toggle.isDisabled(), null); } writer.writeAttribute("type", "checkbox", null); writer.writeAttribute("checked", checked, null); writer.endElement("input"); writer.startElement("span", null); writer.writeAttribute("class", "lever", null); writer.endElement("span"); if(toggle.getItemLabel() != null){ writer.write(toggle.getItemLabel()); } writer.endElement("label"); writer.endElement("div"); } private void encodeScript(FacesContext context, Toggle toggle) throws IOException { String clientId = toggle.getClientId(); String widgetVar = toggle.resolveWidgetVar();
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // } // Path: src/main/java/org/primefaces/material/component/toggle/ToggleRenderer.java import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.convert.ConverterException; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.ComponentUtils; import org.primefaces.util.WidgetBuilder; writer.startElement("div", toggle); writer.writeAttribute("id", toggle.getClientId(), null); writer.writeAttribute("class", "switch", null); writer.startElement("label", null); writer.startElement("input", null); writer.writeAttribute("id", inputId, null); writer.writeAttribute("name", inputId, null); if(toggle.getTabindex() != null){ writer.writeAttribute("tabindex", toggle.getTabindex(), null); } if(toggle.isDisabled()){ writer.writeAttribute("disabled", toggle.isDisabled(), null); } writer.writeAttribute("type", "checkbox", null); writer.writeAttribute("checked", checked, null); writer.endElement("input"); writer.startElement("span", null); writer.writeAttribute("class", "lever", null); writer.endElement("span"); if(toggle.getItemLabel() != null){ writer.write(toggle.getItemLabel()); } writer.endElement("label"); writer.endElement("div"); } private void encodeScript(FacesContext context, Toggle toggle) throws IOException { String clientId = toggle.getClientId(); String widgetVar = toggle.resolveWidgetVar();
WidgetBuilder wb = MaterialWidgetBuilder.getInstance(context);
MaterialPrime/material-prime
src/main/java/org/primefaces/material/component/radiobutton/RadioButtonRenderer.java
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // }
import java.io.IOException; import java.util.List; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.model.SelectItem; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.InputRenderer; import org.primefaces.util.WidgetBuilder;
writer.writeAttribute("checked", selectItem.getValue().equals(radioButton.getValue())? "checked" : "", null); writer.endElement("input"); writer.startElement("label", null); writer.writeAttribute("for", inputId+i, null); writer.write(selectItem.getLabel()); writer.endElement("label"); writer.endElement("p"); } writer.endElement("div"); } private String getInputClass(RadioButton radioButton) { String toReturn = ""; toReturn += radioButton.getStyleClass(); if(radioButton.isWithGap()){ toReturn += " with-gap "; } return toReturn; } private void encodeScript(FacesContext context, RadioButton radioButton) throws IOException { String clientId = radioButton.getClientId(); String widgetVar = radioButton.resolveWidgetVar();
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // } // Path: src/main/java/org/primefaces/material/component/radiobutton/RadioButtonRenderer.java import java.io.IOException; import java.util.List; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.model.SelectItem; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.InputRenderer; import org.primefaces.util.WidgetBuilder; writer.writeAttribute("checked", selectItem.getValue().equals(radioButton.getValue())? "checked" : "", null); writer.endElement("input"); writer.startElement("label", null); writer.writeAttribute("for", inputId+i, null); writer.write(selectItem.getLabel()); writer.endElement("label"); writer.endElement("p"); } writer.endElement("div"); } private String getInputClass(RadioButton radioButton) { String toReturn = ""; toReturn += radioButton.getStyleClass(); if(radioButton.isWithGap()){ toReturn += " with-gap "; } return toReturn; } private void encodeScript(FacesContext context, RadioButton radioButton) throws IOException { String clientId = radioButton.getClientId(); String widgetVar = radioButton.resolveWidgetVar();
WidgetBuilder wb = MaterialWidgetBuilder.getInstance(context);
MaterialPrime/material-prime
src/main/java/org/primefaces/material/component/scrollfire/ScrollFireRenderer.java
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // }
import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.event.ActionEvent; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder;
package org.primefaces.material.component.scrollfire; public class ScrollFireRenderer extends CoreRenderer { public static final String RENDERER_TYPE = "org.primefaces.material.component.ScrollFireRenderer"; @Override public void decode(FacesContext context, UIComponent scrollFire) { String param = scrollFire.getClientId(context); if(context.getExternalContext().getRequestParameterMap().containsKey(param)) { scrollFire.queueEvent(new ActionEvent(scrollFire)); } decodeBehaviors(context, scrollFire); } @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ScrollFire scrollFire = (ScrollFire) component; encodeMarkup(context, scrollFire); encodeScript(context, scrollFire); } private void encodeScript(FacesContext context, ScrollFire scrollFire) throws IOException { String clientId = scrollFire.getClientId(); String widgetVar = scrollFire.resolveWidgetVar();
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // } // Path: src/main/java/org/primefaces/material/component/scrollfire/ScrollFireRenderer.java import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.event.ActionEvent; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder; package org.primefaces.material.component.scrollfire; public class ScrollFireRenderer extends CoreRenderer { public static final String RENDERER_TYPE = "org.primefaces.material.component.ScrollFireRenderer"; @Override public void decode(FacesContext context, UIComponent scrollFire) { String param = scrollFire.getClientId(context); if(context.getExternalContext().getRequestParameterMap().containsKey(param)) { scrollFire.queueEvent(new ActionEvent(scrollFire)); } decodeBehaviors(context, scrollFire); } @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ScrollFire scrollFire = (ScrollFire) component; encodeMarkup(context, scrollFire); encodeScript(context, scrollFire); } private void encodeScript(FacesContext context, ScrollFire scrollFire) throws IOException { String clientId = scrollFire.getClientId(); String widgetVar = scrollFire.resolveWidgetVar();
WidgetBuilder wb = MaterialWidgetBuilder.getInstance(context);
MaterialPrime/material-prime
src/main/java/org/primefaces/material/component/checkbox/CheckboxRenderer.java
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // }
import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.convert.ConverterException; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.ComponentUtils; import org.primefaces.util.WidgetBuilder;
writer.startElement("p", checkbox); writer.writeAttribute("id", checkbox.getClientId(), null); writer.startElement("input", null); writer.writeAttribute("id", inputId, null); writer.writeAttribute("class", "checkbox", null); writer.writeAttribute("name", inputId, null); if(checkbox.getTabindex() != null){ writer.writeAttribute("tabindex", checkbox.getTabindex(), null); } if(checkbox.isDisabled()){ writer.writeAttribute("disabled", checkbox.isDisabled(), null); } writer.writeAttribute("type", "checkbox", null); writer.writeAttribute("checked", checked, null); writer.endElement("input"); writer.startElement("label", null); writer.writeAttribute("for", inputId, null); writer.write(checkbox.getItemLabel()); writer.endElement("label"); writer.endElement("p"); } private void encodeScript(FacesContext context, Checkbox checkbox) throws IOException { String clientId = checkbox.getClientId(); String widgetVar = checkbox.resolveWidgetVar();
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // } // Path: src/main/java/org/primefaces/material/component/checkbox/CheckboxRenderer.java import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.convert.ConverterException; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.ComponentUtils; import org.primefaces.util.WidgetBuilder; writer.startElement("p", checkbox); writer.writeAttribute("id", checkbox.getClientId(), null); writer.startElement("input", null); writer.writeAttribute("id", inputId, null); writer.writeAttribute("class", "checkbox", null); writer.writeAttribute("name", inputId, null); if(checkbox.getTabindex() != null){ writer.writeAttribute("tabindex", checkbox.getTabindex(), null); } if(checkbox.isDisabled()){ writer.writeAttribute("disabled", checkbox.isDisabled(), null); } writer.writeAttribute("type", "checkbox", null); writer.writeAttribute("checked", checked, null); writer.endElement("input"); writer.startElement("label", null); writer.writeAttribute("for", inputId, null); writer.write(checkbox.getItemLabel()); writer.endElement("label"); writer.endElement("p"); } private void encodeScript(FacesContext context, Checkbox checkbox) throws IOException { String clientId = checkbox.getClientId(); String widgetVar = checkbox.resolveWidgetVar();
WidgetBuilder wb = MaterialWidgetBuilder.getInstance(context);
MaterialPrime/material-prime
src/main/java/org/primefaces/material/component/range/RangeRenderer.java
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // }
import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder;
private void encodeMarkup(FacesContext context, Range range) throws IOException { ResponseWriter writer = context.getResponseWriter(); String inputId = range.getClientId() + "_input"; Object value = range.getValue() != null ? range.getValue() : range.getMin(); writer.startElement("p", range); writer.writeAttribute("id", range.getClientId(), null); writer.writeAttribute("class", "range-field", null); writer.startElement("input", null); writer.writeAttribute("id", inputId, null); writer.writeAttribute("name", inputId, null); writer.writeAttribute("value", value, null); writer.writeAttribute("min", range.getMin(), "min"); writer.writeAttribute("max", range.getMax(), "max"); if(range.isDisabled()){ writer.writeAttribute("disabled", range.isDisabled(), null); } writer.writeAttribute("type", "range", null); writer.endElement("input"); writer.endElement("p"); } private void encodeScript(FacesContext context, Range checkbox) throws IOException { String clientId = checkbox.getClientId(); String widgetVar = checkbox.resolveWidgetVar();
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // } // Path: src/main/java/org/primefaces/material/component/range/RangeRenderer.java import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder; private void encodeMarkup(FacesContext context, Range range) throws IOException { ResponseWriter writer = context.getResponseWriter(); String inputId = range.getClientId() + "_input"; Object value = range.getValue() != null ? range.getValue() : range.getMin(); writer.startElement("p", range); writer.writeAttribute("id", range.getClientId(), null); writer.writeAttribute("class", "range-field", null); writer.startElement("input", null); writer.writeAttribute("id", inputId, null); writer.writeAttribute("name", inputId, null); writer.writeAttribute("value", value, null); writer.writeAttribute("min", range.getMin(), "min"); writer.writeAttribute("max", range.getMax(), "max"); if(range.isDisabled()){ writer.writeAttribute("disabled", range.isDisabled(), null); } writer.writeAttribute("type", "range", null); writer.endElement("input"); writer.endElement("p"); } private void encodeScript(FacesContext context, Range checkbox) throws IOException { String clientId = checkbox.getClientId(); String widgetVar = checkbox.resolveWidgetVar();
WidgetBuilder wb = MaterialWidgetBuilder.getInstance(context);
MaterialPrime/material-prime
src/main/java/org/primefaces/material/component/toast/ToastRenderer.java
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // }
import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder;
package org.primefaces.material.component.toast; public class ToastRenderer extends CoreRenderer{ public static final String RENDERER_TYPE = "org.primefaces.material.component.ToastRenderer"; @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { Toast toast = (Toast) component; encodeMarkup(context, toast); encodeScript(context, toast); } private void encodeScript(FacesContext context, Toast toast) throws IOException { String clientId = toast.getClientId(); String widgetVar = toast.resolveWidgetVar();
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java // public class MaterialWidgetBuilder extends WidgetBuilder { // // private static final String KEY = MaterialWidgetBuilder.class.getName(); // // public static MaterialWidgetBuilder getInstance(final FacesContext context) { // // MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY); // // if (wb == null) { // wb = new MaterialWidgetBuilder(context); // // context.getExternalContext().getRequestMap().put(KEY, wb); // } // // return wb; // } // // public MaterialWidgetBuilder(FacesContext context) { // super(context); // } // // protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException { // this.endFunction = endFunction; // // context.getResponseWriter().write("MaterialPrime.cw(\""); // context.getResponseWriter().write(widgetClass); // context.getResponseWriter().write("\",\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\",{"); // context.getResponseWriter().write("id:\""); // context.getResponseWriter().write(id); // if (widgetVar == null) { // context.getResponseWriter().write("\""); // } else { // context.getResponseWriter().write("\",widgetVar:\""); // context.getResponseWriter().write(widgetVar); // context.getResponseWriter().write("\""); // } // // return this; // } // } // Path: src/main/java/org/primefaces/material/component/toast/ToastRenderer.java import java.io.IOException; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import org.primefaces.material.MaterialWidgetBuilder; import org.primefaces.renderkit.CoreRenderer; import org.primefaces.util.WidgetBuilder; package org.primefaces.material.component.toast; public class ToastRenderer extends CoreRenderer{ public static final String RENDERER_TYPE = "org.primefaces.material.component.ToastRenderer"; @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { Toast toast = (Toast) component; encodeMarkup(context, toast); encodeScript(context, toast); } private void encodeScript(FacesContext context, Toast toast) throws IOException { String clientId = toast.getClientId(); String widgetVar = toast.resolveWidgetVar();
WidgetBuilder wb = MaterialWidgetBuilder.getInstance(context);
dektar/jterm-cswithandroid
WordLadder_solution/app/src/test/java/com/google/engedu/worldladder/SimpleWordGraphTest.java
// Path: WordLadder_solution/app/src/main/java/com/google/engedu/wordladder/SimpleWordGraph.java // public class SimpleWordGraph implements WordGraph { // HashMap<String, ArrayList<String>> graph = new HashMap<>(); // // public SimpleWordGraph() { // // } // // @Override // public ArrayList<String> getNeighbors(String word) { // if (graph.containsKey(word)) { // return graph.get(word); // } // return null; // } // // @Override // public void addWord(String word) { // ArrayList<String> neighbors = new ArrayList<>(); // // This is O(N^2), not very efficient! // for (String next : graph.keySet()) { // if (isNeighbor(word, next)) { // neighbors.add(next); // graph.get(next).add(word); // } // } // graph.put(word, neighbors); // } // // @Override // public boolean isWord(String word) { // return graph.containsKey(word); // } // // /** // * Compares two words to see if they are neighbors, i.e. if they are equal in all but one // * character. // * @param word1 // * @param word2 // * @return // */ // @VisibleForTesting // boolean isNeighbor(String word1, String word2) { // if (word1 == null || word2 == null || word1.length() != word2.length()) { // // The words need to be the same length. // return false; // } // int diffCount = 0; // for (int i = 0; i < word1.length(); i++) { // if (!word1.substring(i, i + 1).equals(word2.substring(i, i + 1))) { // diffCount++; // if (diffCount > 1) { // // Stop early when we've found more than one difference. // return false; // } // } // } // return diffCount == 1; // } // } // // Path: WordLadder_solution/app/src/main/java/com/google/engedu/wordladder/WordGraph.java // public interface WordGraph { // /** // * Gets the neighbors of a word, i.e. other words that differ in just one character. // * @param word // * @return The list of neighboring words, or null if word is not in the dict. // */ // ArrayList<String> getNeighbors(String word); // // /** // * Adds a word to the graph. // * @param word // */ // void addWord(String word); // // /** // * Checks whether a word is in the graph. // * @param word // * @return true if the word is in the graph. // */ // boolean isWord(String word); // }
import com.google.engedu.wordladder.SimpleWordGraph; import com.google.engedu.wordladder.WordGraph; import org.junit.Test; import static org.junit.Assert.*;
/* * Copyright 2016 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.engedu.worldladder; public class SimpleWordGraphTest { @Test public void testGetNeighbors() {
// Path: WordLadder_solution/app/src/main/java/com/google/engedu/wordladder/SimpleWordGraph.java // public class SimpleWordGraph implements WordGraph { // HashMap<String, ArrayList<String>> graph = new HashMap<>(); // // public SimpleWordGraph() { // // } // // @Override // public ArrayList<String> getNeighbors(String word) { // if (graph.containsKey(word)) { // return graph.get(word); // } // return null; // } // // @Override // public void addWord(String word) { // ArrayList<String> neighbors = new ArrayList<>(); // // This is O(N^2), not very efficient! // for (String next : graph.keySet()) { // if (isNeighbor(word, next)) { // neighbors.add(next); // graph.get(next).add(word); // } // } // graph.put(word, neighbors); // } // // @Override // public boolean isWord(String word) { // return graph.containsKey(word); // } // // /** // * Compares two words to see if they are neighbors, i.e. if they are equal in all but one // * character. // * @param word1 // * @param word2 // * @return // */ // @VisibleForTesting // boolean isNeighbor(String word1, String word2) { // if (word1 == null || word2 == null || word1.length() != word2.length()) { // // The words need to be the same length. // return false; // } // int diffCount = 0; // for (int i = 0; i < word1.length(); i++) { // if (!word1.substring(i, i + 1).equals(word2.substring(i, i + 1))) { // diffCount++; // if (diffCount > 1) { // // Stop early when we've found more than one difference. // return false; // } // } // } // return diffCount == 1; // } // } // // Path: WordLadder_solution/app/src/main/java/com/google/engedu/wordladder/WordGraph.java // public interface WordGraph { // /** // * Gets the neighbors of a word, i.e. other words that differ in just one character. // * @param word // * @return The list of neighboring words, or null if word is not in the dict. // */ // ArrayList<String> getNeighbors(String word); // // /** // * Adds a word to the graph. // * @param word // */ // void addWord(String word); // // /** // * Checks whether a word is in the graph. // * @param word // * @return true if the word is in the graph. // */ // boolean isWord(String word); // } // Path: WordLadder_solution/app/src/test/java/com/google/engedu/worldladder/SimpleWordGraphTest.java import com.google.engedu.wordladder.SimpleWordGraph; import com.google.engedu.wordladder.WordGraph; import org.junit.Test; import static org.junit.Assert.*; /* * Copyright 2016 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.engedu.worldladder; public class SimpleWordGraphTest { @Test public void testGetNeighbors() {
SimpleWordGraph graph = new SimpleWordGraph();
comcp/android-Stupid-Adapter
StupidAdapter.ExpandAdapter/src/com/stupid/method/adapter/expand/XExpadnAdapter.java
// Path: StupidAdapter/src/com/stupid/method/adapter/OnClickItemListener.java // public interface OnClickItemListener { // public void onClickItem(View v, int position); // // } // // Path: StupidAdapter/src/com/stupid/method/adapter/XAdapter2.java // public class XAdapter2<T> extends XAdapter<T> implements IXAdapter<T> { // private static final String tag = "XAdapter2"; // private OnClickItemListener clickItemListener; // private OnLongClickItemListener longClickItemListener; // private Class<? extends IXViewHolder<T>> viewBean; // // public XAdapter2(Context context, List<T> mData, // Class<? extends IXViewHolder<T>> xViewHolder) { // super(context, mData, null); // super.setAdapterInterface(this); // if (xViewHolder == null) // throw new NullPointerException( // "XAdapter2(context,List,Class) :最后一个参数 class 不能为空"); // this.viewBean = xViewHolder; // // } // // public XAdapter2(Context context, // Class<? extends IXViewHolder<T>> xViewHolder) { // this(context, null, xViewHolder); // } // // /** // * 增加String 载入class, // * // * 可以通过 配置文件动态载入不同viewHolder // * // * 好像是没什么卵用. // * // * **/ // @SuppressWarnings("unchecked") // public XAdapter2(Context context, String className) // throws ClassNotFoundException { // this(context, null, (Class<? extends IXViewHolder<T>>) Class // .forName(className)); // } // // @Override // public View convertView(int position, View convertView, ViewGroup parent, // List<T> mData, LayoutInflater inflater) { // IXViewHolder<T> holder = null; // // if (convertView == null // || !(convertView.getTag() instanceof IXViewHolder)) { // // if (viewBean != null) { // // try { // holder = (IXViewHolder<T>) viewBean.newInstance(); // holder.setInflater(inflater, parent); // holder.onCreate(context); // holder.setOnClickItemListener(this.clickItemListener); // holder.setOnLongClickItemListener(longClickItemListener); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // // } else { // Log.e(tag, "没有设置 IXViewHolder "); // return super.getView(position, convertView, parent); // } // // } else { // holder = (IXViewHolder<T>) convertView.getTag(); // holder.onDestory(position, getCount()); // } // if (holder != null) { // holder.setListSize(getCount()); // return holder.getView(mData.get(position), position, // isOnScrolling()); // } else // return super.getView(position, convertView, parent); // } // // public OnClickItemListener getClickItemListener() { // return clickItemListener; // } // // public OnLongClickItemListener getLongClickItemListener() { // return longClickItemListener; // } // // public void setClickItemListener(OnClickItemListener clickItemListener) { // this.clickItemListener = clickItemListener; // } // // public void setLongClickItemListener( // OnLongClickItemListener longClickItemListener) { // this.longClickItemListener = longClickItemListener; // } // }
import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import android.content.Context; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.BaseExpandableListAdapter; import com.stupid.method.adapter.OnClickItemListener; import com.stupid.method.adapter.XAdapter2;
package com.stupid.method.adapter.expand; public class XExpadnAdapter<ParentModel, ChildModel> extends BaseExpandableListAdapter { private OnXItemClickListener onItemClickListener;
// Path: StupidAdapter/src/com/stupid/method/adapter/OnClickItemListener.java // public interface OnClickItemListener { // public void onClickItem(View v, int position); // // } // // Path: StupidAdapter/src/com/stupid/method/adapter/XAdapter2.java // public class XAdapter2<T> extends XAdapter<T> implements IXAdapter<T> { // private static final String tag = "XAdapter2"; // private OnClickItemListener clickItemListener; // private OnLongClickItemListener longClickItemListener; // private Class<? extends IXViewHolder<T>> viewBean; // // public XAdapter2(Context context, List<T> mData, // Class<? extends IXViewHolder<T>> xViewHolder) { // super(context, mData, null); // super.setAdapterInterface(this); // if (xViewHolder == null) // throw new NullPointerException( // "XAdapter2(context,List,Class) :最后一个参数 class 不能为空"); // this.viewBean = xViewHolder; // // } // // public XAdapter2(Context context, // Class<? extends IXViewHolder<T>> xViewHolder) { // this(context, null, xViewHolder); // } // // /** // * 增加String 载入class, // * // * 可以通过 配置文件动态载入不同viewHolder // * // * 好像是没什么卵用. // * // * **/ // @SuppressWarnings("unchecked") // public XAdapter2(Context context, String className) // throws ClassNotFoundException { // this(context, null, (Class<? extends IXViewHolder<T>>) Class // .forName(className)); // } // // @Override // public View convertView(int position, View convertView, ViewGroup parent, // List<T> mData, LayoutInflater inflater) { // IXViewHolder<T> holder = null; // // if (convertView == null // || !(convertView.getTag() instanceof IXViewHolder)) { // // if (viewBean != null) { // // try { // holder = (IXViewHolder<T>) viewBean.newInstance(); // holder.setInflater(inflater, parent); // holder.onCreate(context); // holder.setOnClickItemListener(this.clickItemListener); // holder.setOnLongClickItemListener(longClickItemListener); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // // } else { // Log.e(tag, "没有设置 IXViewHolder "); // return super.getView(position, convertView, parent); // } // // } else { // holder = (IXViewHolder<T>) convertView.getTag(); // holder.onDestory(position, getCount()); // } // if (holder != null) { // holder.setListSize(getCount()); // return holder.getView(mData.get(position), position, // isOnScrolling()); // } else // return super.getView(position, convertView, parent); // } // // public OnClickItemListener getClickItemListener() { // return clickItemListener; // } // // public OnLongClickItemListener getLongClickItemListener() { // return longClickItemListener; // } // // public void setClickItemListener(OnClickItemListener clickItemListener) { // this.clickItemListener = clickItemListener; // } // // public void setLongClickItemListener( // OnLongClickItemListener longClickItemListener) { // this.longClickItemListener = longClickItemListener; // } // } // Path: StupidAdapter.ExpandAdapter/src/com/stupid/method/adapter/expand/XExpadnAdapter.java import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import android.content.Context; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.BaseExpandableListAdapter; import com.stupid.method.adapter.OnClickItemListener; import com.stupid.method.adapter.XAdapter2; package com.stupid.method.adapter.expand; public class XExpadnAdapter<ParentModel, ChildModel> extends BaseExpandableListAdapter { private OnXItemClickListener onItemClickListener;
final Map<ParentModel, XAdapter2<ChildModel>> mMap;
comcp/android-Stupid-Adapter
StupidAdapter.ExpandAdapter/src/com/stupid/method/adapter/expand/XExpadnAdapter.java
// Path: StupidAdapter/src/com/stupid/method/adapter/OnClickItemListener.java // public interface OnClickItemListener { // public void onClickItem(View v, int position); // // } // // Path: StupidAdapter/src/com/stupid/method/adapter/XAdapter2.java // public class XAdapter2<T> extends XAdapter<T> implements IXAdapter<T> { // private static final String tag = "XAdapter2"; // private OnClickItemListener clickItemListener; // private OnLongClickItemListener longClickItemListener; // private Class<? extends IXViewHolder<T>> viewBean; // // public XAdapter2(Context context, List<T> mData, // Class<? extends IXViewHolder<T>> xViewHolder) { // super(context, mData, null); // super.setAdapterInterface(this); // if (xViewHolder == null) // throw new NullPointerException( // "XAdapter2(context,List,Class) :最后一个参数 class 不能为空"); // this.viewBean = xViewHolder; // // } // // public XAdapter2(Context context, // Class<? extends IXViewHolder<T>> xViewHolder) { // this(context, null, xViewHolder); // } // // /** // * 增加String 载入class, // * // * 可以通过 配置文件动态载入不同viewHolder // * // * 好像是没什么卵用. // * // * **/ // @SuppressWarnings("unchecked") // public XAdapter2(Context context, String className) // throws ClassNotFoundException { // this(context, null, (Class<? extends IXViewHolder<T>>) Class // .forName(className)); // } // // @Override // public View convertView(int position, View convertView, ViewGroup parent, // List<T> mData, LayoutInflater inflater) { // IXViewHolder<T> holder = null; // // if (convertView == null // || !(convertView.getTag() instanceof IXViewHolder)) { // // if (viewBean != null) { // // try { // holder = (IXViewHolder<T>) viewBean.newInstance(); // holder.setInflater(inflater, parent); // holder.onCreate(context); // holder.setOnClickItemListener(this.clickItemListener); // holder.setOnLongClickItemListener(longClickItemListener); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // // } else { // Log.e(tag, "没有设置 IXViewHolder "); // return super.getView(position, convertView, parent); // } // // } else { // holder = (IXViewHolder<T>) convertView.getTag(); // holder.onDestory(position, getCount()); // } // if (holder != null) { // holder.setListSize(getCount()); // return holder.getView(mData.get(position), position, // isOnScrolling()); // } else // return super.getView(position, convertView, parent); // } // // public OnClickItemListener getClickItemListener() { // return clickItemListener; // } // // public OnLongClickItemListener getLongClickItemListener() { // return longClickItemListener; // } // // public void setClickItemListener(OnClickItemListener clickItemListener) { // this.clickItemListener = clickItemListener; // } // // public void setLongClickItemListener( // OnLongClickItemListener longClickItemListener) { // this.longClickItemListener = longClickItemListener; // } // }
import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import android.content.Context; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.BaseExpandableListAdapter; import com.stupid.method.adapter.OnClickItemListener; import com.stupid.method.adapter.XAdapter2;
package com.stupid.method.adapter.expand; public class XExpadnAdapter<ParentModel, ChildModel> extends BaseExpandableListAdapter { private OnXItemClickListener onItemClickListener; final Map<ParentModel, XAdapter2<ChildModel>> mMap; final XAdapter2<ParentModel> parentAdapter; final Class<? extends XExpadnViewHolder<ParentModel>> parentViewClass; final Class<? extends XExpadnViewHolder<ChildModel>> childViewClass; final Context mContext;
// Path: StupidAdapter/src/com/stupid/method/adapter/OnClickItemListener.java // public interface OnClickItemListener { // public void onClickItem(View v, int position); // // } // // Path: StupidAdapter/src/com/stupid/method/adapter/XAdapter2.java // public class XAdapter2<T> extends XAdapter<T> implements IXAdapter<T> { // private static final String tag = "XAdapter2"; // private OnClickItemListener clickItemListener; // private OnLongClickItemListener longClickItemListener; // private Class<? extends IXViewHolder<T>> viewBean; // // public XAdapter2(Context context, List<T> mData, // Class<? extends IXViewHolder<T>> xViewHolder) { // super(context, mData, null); // super.setAdapterInterface(this); // if (xViewHolder == null) // throw new NullPointerException( // "XAdapter2(context,List,Class) :最后一个参数 class 不能为空"); // this.viewBean = xViewHolder; // // } // // public XAdapter2(Context context, // Class<? extends IXViewHolder<T>> xViewHolder) { // this(context, null, xViewHolder); // } // // /** // * 增加String 载入class, // * // * 可以通过 配置文件动态载入不同viewHolder // * // * 好像是没什么卵用. // * // * **/ // @SuppressWarnings("unchecked") // public XAdapter2(Context context, String className) // throws ClassNotFoundException { // this(context, null, (Class<? extends IXViewHolder<T>>) Class // .forName(className)); // } // // @Override // public View convertView(int position, View convertView, ViewGroup parent, // List<T> mData, LayoutInflater inflater) { // IXViewHolder<T> holder = null; // // if (convertView == null // || !(convertView.getTag() instanceof IXViewHolder)) { // // if (viewBean != null) { // // try { // holder = (IXViewHolder<T>) viewBean.newInstance(); // holder.setInflater(inflater, parent); // holder.onCreate(context); // holder.setOnClickItemListener(this.clickItemListener); // holder.setOnLongClickItemListener(longClickItemListener); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // // } else { // Log.e(tag, "没有设置 IXViewHolder "); // return super.getView(position, convertView, parent); // } // // } else { // holder = (IXViewHolder<T>) convertView.getTag(); // holder.onDestory(position, getCount()); // } // if (holder != null) { // holder.setListSize(getCount()); // return holder.getView(mData.get(position), position, // isOnScrolling()); // } else // return super.getView(position, convertView, parent); // } // // public OnClickItemListener getClickItemListener() { // return clickItemListener; // } // // public OnLongClickItemListener getLongClickItemListener() { // return longClickItemListener; // } // // public void setClickItemListener(OnClickItemListener clickItemListener) { // this.clickItemListener = clickItemListener; // } // // public void setLongClickItemListener( // OnLongClickItemListener longClickItemListener) { // this.longClickItemListener = longClickItemListener; // } // } // Path: StupidAdapter.ExpandAdapter/src/com/stupid/method/adapter/expand/XExpadnAdapter.java import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import android.content.Context; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.BaseExpandableListAdapter; import com.stupid.method.adapter.OnClickItemListener; import com.stupid.method.adapter.XAdapter2; package com.stupid.method.adapter.expand; public class XExpadnAdapter<ParentModel, ChildModel> extends BaseExpandableListAdapter { private OnXItemClickListener onItemClickListener; final Map<ParentModel, XAdapter2<ChildModel>> mMap; final XAdapter2<ParentModel> parentAdapter; final Class<? extends XExpadnViewHolder<ParentModel>> parentViewClass; final Class<? extends XExpadnViewHolder<ChildModel>> childViewClass; final Context mContext;
private class OnClickItemListenerImpl implements OnClickItemListener {
comcp/android-Stupid-Adapter
StupidAdapter.RecyclerViewAdapter/src/com/stupid/method/adapter/IPauseOnScrollRecycler.java
// Path: StupidAdapter/src/com/stupid/method/adapter/IPauseOnScroll.java // interface IXPauseListener { // void onResume(); // // void onPause(); // }
import com.stupid.method.adapter.IPauseOnScroll.IXPauseListener; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.OnScrollListener;
package com.stupid.method.adapter; public class IPauseOnScrollRecycler extends OnScrollListener { private OnScrollListener listener2;
// Path: StupidAdapter/src/com/stupid/method/adapter/IPauseOnScroll.java // interface IXPauseListener { // void onResume(); // // void onPause(); // } // Path: StupidAdapter.RecyclerViewAdapter/src/com/stupid/method/adapter/IPauseOnScrollRecycler.java import com.stupid.method.adapter.IPauseOnScroll.IXPauseListener; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.OnScrollListener; package com.stupid.method.adapter; public class IPauseOnScrollRecycler extends OnScrollListener { private OnScrollListener listener2;
IXPauseListener adapter;
SeleniumBuilder/SeInterpreter-Java
src/com/sebuilder/interpreter/datasource/Json.java
// Path: src/com/sebuilder/interpreter/DataSource.java // public interface DataSource { // public List<Map<String, String>> getData(Map<String, String> config, File relativeTo); // } // // Path: src/com/sebuilder/interpreter/datasource/Utils.java // public static File findFile(File relativeTo, String path) { // if (relativeTo != null) { // File f = new File(relativeTo, path); // if (f.exists()) { // return f; // } // } // return new File(path); // }
import com.sebuilder.interpreter.DataSource; import static com.sebuilder.interpreter.datasource.Utils.findFile; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.json.JSONArray; import org.json.JSONObject; import org.json.JSONTokener;
/* * Copyright 2014 Sauce Labs * * 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.sebuilder.interpreter.datasource; /** * JSON-based data source. * @author zarkonnen */ public class Json implements DataSource { @Override public List<Map<String, String>> getData(Map<String, String> config, File relativeTo) { ArrayList<Map<String, String>> data = new ArrayList<Map<String, String>>();
// Path: src/com/sebuilder/interpreter/DataSource.java // public interface DataSource { // public List<Map<String, String>> getData(Map<String, String> config, File relativeTo); // } // // Path: src/com/sebuilder/interpreter/datasource/Utils.java // public static File findFile(File relativeTo, String path) { // if (relativeTo != null) { // File f = new File(relativeTo, path); // if (f.exists()) { // return f; // } // } // return new File(path); // } // Path: src/com/sebuilder/interpreter/datasource/Json.java import com.sebuilder.interpreter.DataSource; import static com.sebuilder.interpreter.datasource.Utils.findFile; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.json.JSONArray; import org.json.JSONObject; import org.json.JSONTokener; /* * Copyright 2014 Sauce Labs * * 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.sebuilder.interpreter.datasource; /** * JSON-based data source. * @author zarkonnen */ public class Json implements DataSource { @Override public List<Map<String, String>> getData(Map<String, String> config, File relativeTo) { ArrayList<Map<String, String>> data = new ArrayList<Map<String, String>>();
File f = findFile(relativeTo, config.get("path"));
SeleniumBuilder/SeInterpreter-Java
src/com/sebuilder/interpreter/datasource/Xml.java
// Path: src/com/sebuilder/interpreter/DataSource.java // public interface DataSource { // public List<Map<String, String>> getData(Map<String, String> config, File relativeTo); // } // // Path: src/com/sebuilder/interpreter/datasource/Utils.java // public static File findFile(File relativeTo, String path) { // if (relativeTo != null) { // File f = new File(relativeTo, path); // if (f.exists()) { // return f; // } // } // return new File(path); // }
import com.sebuilder.interpreter.DataSource; import static com.sebuilder.interpreter.datasource.Utils.findFile; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList;
/* * Copyright 2014 Sauce Labs * * 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.sebuilder.interpreter.datasource; /** * XML data source compatible with the standard IDE approach. * @author zarkonnen */ public class Xml implements DataSource { @Override public List<Map<String, String>> getData(Map<String, String> config, File relativeTo) { ArrayList<Map<String, String>> data = new ArrayList<Map<String, String>>();
// Path: src/com/sebuilder/interpreter/DataSource.java // public interface DataSource { // public List<Map<String, String>> getData(Map<String, String> config, File relativeTo); // } // // Path: src/com/sebuilder/interpreter/datasource/Utils.java // public static File findFile(File relativeTo, String path) { // if (relativeTo != null) { // File f = new File(relativeTo, path); // if (f.exists()) { // return f; // } // } // return new File(path); // } // Path: src/com/sebuilder/interpreter/datasource/Xml.java import com.sebuilder.interpreter.DataSource; import static com.sebuilder.interpreter.datasource.Utils.findFile; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /* * Copyright 2014 Sauce Labs * * 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.sebuilder.interpreter.datasource; /** * XML data source compatible with the standard IDE approach. * @author zarkonnen */ public class Xml implements DataSource { @Override public List<Map<String, String>> getData(Map<String, String> config, File relativeTo) { ArrayList<Map<String, String>> data = new ArrayList<Map<String, String>>();
File f = findFile(relativeTo, config.get("path"));
SeleniumBuilder/SeInterpreter-Java
src/com/sebuilder/interpreter/TestRun.java
// Path: src/com/sebuilder/interpreter/webdriverfactory/WebDriverFactory.java // public interface WebDriverFactory { // /** // * @param config A key/value mapping of configuration options specific to this factory. // * @return A RemoteWebDriver of the type produced by this factory. // */ // public RemoteWebDriver make(HashMap<String, String> config) throws Exception; // }
import com.sebuilder.interpreter.webdriverfactory.WebDriverFactory; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openqa.selenium.Keys; import org.openqa.selenium.remote.RemoteWebDriver;
/* * Copyright 2012 Sauce Labs * * 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.sebuilder.interpreter; /** * A single run of a test script. * @author zarkonnen */ public class TestRun { HashMap<String, String> vars = new HashMap<String, String>(); Script script; protected int stepIndex = -1; RemoteWebDriver driver; Log log;
// Path: src/com/sebuilder/interpreter/webdriverfactory/WebDriverFactory.java // public interface WebDriverFactory { // /** // * @param config A key/value mapping of configuration options specific to this factory. // * @return A RemoteWebDriver of the type produced by this factory. // */ // public RemoteWebDriver make(HashMap<String, String> config) throws Exception; // } // Path: src/com/sebuilder/interpreter/TestRun.java import com.sebuilder.interpreter.webdriverfactory.WebDriverFactory; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openqa.selenium.Keys; import org.openqa.selenium.remote.RemoteWebDriver; /* * Copyright 2012 Sauce Labs * * 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.sebuilder.interpreter; /** * A single run of a test script. * @author zarkonnen */ public class TestRun { HashMap<String, String> vars = new HashMap<String, String>(); Script script; protected int stepIndex = -1; RemoteWebDriver driver; Log log;
WebDriverFactory webDriverFactory = SeInterpreter.DEFAULT_DRIVER_FACTORY;
SeleniumBuilder/SeInterpreter-Java
src/com/sebuilder/interpreter/datasource/Csv.java
// Path: src/com/sebuilder/interpreter/DataSource.java // public interface DataSource { // public List<Map<String, String>> getData(Map<String, String> config, File relativeTo); // } // // Path: src/com/sebuilder/interpreter/datasource/Utils.java // public static File findFile(File relativeTo, String path) { // if (relativeTo != null) { // File f = new File(relativeTo, path); // if (f.exists()) { // return f; // } // } // return new File(path); // }
import au.com.bytecode.opencsv.CSVReader; import com.sebuilder.interpreter.DataSource; import static com.sebuilder.interpreter.datasource.Utils.findFile; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright 2014 Sauce Labs * * 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.sebuilder.interpreter.datasource; /** * CSV-based data source. * @author zarkonnen */ public class Csv implements DataSource { @Override public List<Map<String, String>> getData(Map<String, String> config, File relativeTo) { ArrayList<Map<String, String>> data = new ArrayList<Map<String, String>>();
// Path: src/com/sebuilder/interpreter/DataSource.java // public interface DataSource { // public List<Map<String, String>> getData(Map<String, String> config, File relativeTo); // } // // Path: src/com/sebuilder/interpreter/datasource/Utils.java // public static File findFile(File relativeTo, String path) { // if (relativeTo != null) { // File f = new File(relativeTo, path); // if (f.exists()) { // return f; // } // } // return new File(path); // } // Path: src/com/sebuilder/interpreter/datasource/Csv.java import au.com.bytecode.opencsv.CSVReader; import com.sebuilder.interpreter.DataSource; import static com.sebuilder.interpreter.datasource.Utils.findFile; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright 2014 Sauce Labs * * 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.sebuilder.interpreter.datasource; /** * CSV-based data source. * @author zarkonnen */ public class Csv implements DataSource { @Override public List<Map<String, String>> getData(Map<String, String> config, File relativeTo) { ArrayList<Map<String, String>> data = new ArrayList<Map<String, String>>();
File f = findFile(relativeTo, config.get("path"));
SeleniumBuilder/SeInterpreter-Java
src/com/sebuilder/interpreter/Script.java
// Path: src/com/sebuilder/interpreter/factory/TestRunFactory.java // public class TestRunFactory { // private int implicitlyWaitDriverTimeout = -1; // private int pageLoadDriverTimeout = -1; // // public int getImplicitlyWaitDriverTimeout() { return implicitlyWaitDriverTimeout; } // public void setImplicitlyWaitDriverTimeout(int implicitlyWaitDriverTimeout) { this.implicitlyWaitDriverTimeout = implicitlyWaitDriverTimeout; } // // public int getPageLoadDriverTimeout() { return pageLoadDriverTimeout; } // public void setPageLoadDriverTimeout(int pageLoadDriverTimeout) { this.pageLoadDriverTimeout = pageLoadDriverTimeout; } // // /** // * @param script // * @return A TestRun for the script // */ // public TestRun createTestRun(Script script) { // return new TestRun(script, implicitlyWaitDriverTimeout, pageLoadDriverTimeout); // } // // /** // * @param script // * @param initialVars // * @return A TestRun for the script // */ // public TestRun createTestRun(Script script, Map<String, String> initialVars) { // return new TestRun(script, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @return A new instance of TestRun // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig) { // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @param initialVars // * @return A new instance of TestRun // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig, Map<String, String> initialVars) { // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @param initialVars // * @param previousRun // * @return A new instance of TestRun, using the previous run's driver and vars if available. // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig, Map<String, String> initialVars, TestRun previousRun) { // if (script.usePreviousDriverAndVars && previousRun != null && previousRun.driver() != null) { // return new TestRun(script, log, previousRun, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // } // // Path: src/com/sebuilder/interpreter/webdriverfactory/WebDriverFactory.java // public interface WebDriverFactory { // /** // * @param config A key/value mapping of configuration options specific to this factory. // * @return A RemoteWebDriver of the type produced by this factory. // */ // public RemoteWebDriver make(HashMap<String, String> config) throws Exception; // }
import com.sebuilder.interpreter.factory.TestRunFactory; import com.sebuilder.interpreter.webdriverfactory.WebDriverFactory; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject;
/* * Copyright 2012 Sauce Labs * * 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.sebuilder.interpreter; /** * A Selenium 2 script. To create and run a test, instantiate a Script object, * add some Script.Steps to its steps, then invoke "run". If you want to be able * to run the script step by step, invoke "start", which will return a TestRun * object. * * @author zarkonnen */ public class Script { public ArrayList<Step> steps = new ArrayList<Step>();
// Path: src/com/sebuilder/interpreter/factory/TestRunFactory.java // public class TestRunFactory { // private int implicitlyWaitDriverTimeout = -1; // private int pageLoadDriverTimeout = -1; // // public int getImplicitlyWaitDriverTimeout() { return implicitlyWaitDriverTimeout; } // public void setImplicitlyWaitDriverTimeout(int implicitlyWaitDriverTimeout) { this.implicitlyWaitDriverTimeout = implicitlyWaitDriverTimeout; } // // public int getPageLoadDriverTimeout() { return pageLoadDriverTimeout; } // public void setPageLoadDriverTimeout(int pageLoadDriverTimeout) { this.pageLoadDriverTimeout = pageLoadDriverTimeout; } // // /** // * @param script // * @return A TestRun for the script // */ // public TestRun createTestRun(Script script) { // return new TestRun(script, implicitlyWaitDriverTimeout, pageLoadDriverTimeout); // } // // /** // * @param script // * @param initialVars // * @return A TestRun for the script // */ // public TestRun createTestRun(Script script, Map<String, String> initialVars) { // return new TestRun(script, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @return A new instance of TestRun // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig) { // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @param initialVars // * @return A new instance of TestRun // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig, Map<String, String> initialVars) { // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @param initialVars // * @param previousRun // * @return A new instance of TestRun, using the previous run's driver and vars if available. // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig, Map<String, String> initialVars, TestRun previousRun) { // if (script.usePreviousDriverAndVars && previousRun != null && previousRun.driver() != null) { // return new TestRun(script, log, previousRun, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // } // // Path: src/com/sebuilder/interpreter/webdriverfactory/WebDriverFactory.java // public interface WebDriverFactory { // /** // * @param config A key/value mapping of configuration options specific to this factory. // * @return A RemoteWebDriver of the type produced by this factory. // */ // public RemoteWebDriver make(HashMap<String, String> config) throws Exception; // } // Path: src/com/sebuilder/interpreter/Script.java import com.sebuilder.interpreter.factory.TestRunFactory; import com.sebuilder.interpreter.webdriverfactory.WebDriverFactory; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* * Copyright 2012 Sauce Labs * * 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.sebuilder.interpreter; /** * A Selenium 2 script. To create and run a test, instantiate a Script object, * add some Script.Steps to its steps, then invoke "run". If you want to be able * to run the script step by step, invoke "start", which will return a TestRun * object. * * @author zarkonnen */ public class Script { public ArrayList<Step> steps = new ArrayList<Step>();
public TestRunFactory testRunFactory = new TestRunFactory();
SeleniumBuilder/SeInterpreter-Java
src/com/sebuilder/interpreter/Script.java
// Path: src/com/sebuilder/interpreter/factory/TestRunFactory.java // public class TestRunFactory { // private int implicitlyWaitDriverTimeout = -1; // private int pageLoadDriverTimeout = -1; // // public int getImplicitlyWaitDriverTimeout() { return implicitlyWaitDriverTimeout; } // public void setImplicitlyWaitDriverTimeout(int implicitlyWaitDriverTimeout) { this.implicitlyWaitDriverTimeout = implicitlyWaitDriverTimeout; } // // public int getPageLoadDriverTimeout() { return pageLoadDriverTimeout; } // public void setPageLoadDriverTimeout(int pageLoadDriverTimeout) { this.pageLoadDriverTimeout = pageLoadDriverTimeout; } // // /** // * @param script // * @return A TestRun for the script // */ // public TestRun createTestRun(Script script) { // return new TestRun(script, implicitlyWaitDriverTimeout, pageLoadDriverTimeout); // } // // /** // * @param script // * @param initialVars // * @return A TestRun for the script // */ // public TestRun createTestRun(Script script, Map<String, String> initialVars) { // return new TestRun(script, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @return A new instance of TestRun // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig) { // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @param initialVars // * @return A new instance of TestRun // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig, Map<String, String> initialVars) { // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @param initialVars // * @param previousRun // * @return A new instance of TestRun, using the previous run's driver and vars if available. // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig, Map<String, String> initialVars, TestRun previousRun) { // if (script.usePreviousDriverAndVars && previousRun != null && previousRun.driver() != null) { // return new TestRun(script, log, previousRun, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // } // // Path: src/com/sebuilder/interpreter/webdriverfactory/WebDriverFactory.java // public interface WebDriverFactory { // /** // * @param config A key/value mapping of configuration options specific to this factory. // * @return A RemoteWebDriver of the type produced by this factory. // */ // public RemoteWebDriver make(HashMap<String, String> config) throws Exception; // }
import com.sebuilder.interpreter.factory.TestRunFactory; import com.sebuilder.interpreter.webdriverfactory.WebDriverFactory; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject;
/* * Copyright 2012 Sauce Labs * * 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.sebuilder.interpreter; /** * A Selenium 2 script. To create and run a test, instantiate a Script object, * add some Script.Steps to its steps, then invoke "run". If you want to be able * to run the script step by step, invoke "start", which will return a TestRun * object. * * @author zarkonnen */ public class Script { public ArrayList<Step> steps = new ArrayList<Step>(); public TestRunFactory testRunFactory = new TestRunFactory(); public List<Map<String, String>> dataRows; public String name = "Script"; public boolean usePreviousDriverAndVars = false; public boolean closeDriver = true; public Script() { // By default there is one empty data row. dataRows = new ArrayList<Map<String, String>>(1); dataRows.add(new HashMap<String, String>()); } /** * @return A TestRun object that can be iterated to run the script step by * step. */ public TestRun start() { return testRunFactory.createTestRun(this); } /** * @param log Logger to log to. * @param webDriverFactory Factory for the WebDriver to use for playback. * @param webDriverConfig Configuration for the factory/WebDriver. * @return A TestRun object that can be iterated to run the script step by * step. */
// Path: src/com/sebuilder/interpreter/factory/TestRunFactory.java // public class TestRunFactory { // private int implicitlyWaitDriverTimeout = -1; // private int pageLoadDriverTimeout = -1; // // public int getImplicitlyWaitDriverTimeout() { return implicitlyWaitDriverTimeout; } // public void setImplicitlyWaitDriverTimeout(int implicitlyWaitDriverTimeout) { this.implicitlyWaitDriverTimeout = implicitlyWaitDriverTimeout; } // // public int getPageLoadDriverTimeout() { return pageLoadDriverTimeout; } // public void setPageLoadDriverTimeout(int pageLoadDriverTimeout) { this.pageLoadDriverTimeout = pageLoadDriverTimeout; } // // /** // * @param script // * @return A TestRun for the script // */ // public TestRun createTestRun(Script script) { // return new TestRun(script, implicitlyWaitDriverTimeout, pageLoadDriverTimeout); // } // // /** // * @param script // * @param initialVars // * @return A TestRun for the script // */ // public TestRun createTestRun(Script script, Map<String, String> initialVars) { // return new TestRun(script, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @return A new instance of TestRun // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig) { // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @param initialVars // * @return A new instance of TestRun // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig, Map<String, String> initialVars) { // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // // /** // * @param script // * @param log // * @param webDriverFactory // * @param webDriverConfig // * @param initialVars // * @param previousRun // * @return A new instance of TestRun, using the previous run's driver and vars if available. // */ // public TestRun createTestRun(Script script, Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig, Map<String, String> initialVars, TestRun previousRun) { // if (script.usePreviousDriverAndVars && previousRun != null && previousRun.driver() != null) { // return new TestRun(script, log, previousRun, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // return new TestRun(script, log, webDriverFactory, webDriverConfig, implicitlyWaitDriverTimeout, pageLoadDriverTimeout, initialVars); // } // } // // Path: src/com/sebuilder/interpreter/webdriverfactory/WebDriverFactory.java // public interface WebDriverFactory { // /** // * @param config A key/value mapping of configuration options specific to this factory. // * @return A RemoteWebDriver of the type produced by this factory. // */ // public RemoteWebDriver make(HashMap<String, String> config) throws Exception; // } // Path: src/com/sebuilder/interpreter/Script.java import com.sebuilder.interpreter.factory.TestRunFactory; import com.sebuilder.interpreter.webdriverfactory.WebDriverFactory; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* * Copyright 2012 Sauce Labs * * 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.sebuilder.interpreter; /** * A Selenium 2 script. To create and run a test, instantiate a Script object, * add some Script.Steps to its steps, then invoke "run". If you want to be able * to run the script step by step, invoke "start", which will return a TestRun * object. * * @author zarkonnen */ public class Script { public ArrayList<Step> steps = new ArrayList<Step>(); public TestRunFactory testRunFactory = new TestRunFactory(); public List<Map<String, String>> dataRows; public String name = "Script"; public boolean usePreviousDriverAndVars = false; public boolean closeDriver = true; public Script() { // By default there is one empty data row. dataRows = new ArrayList<Map<String, String>>(1); dataRows.add(new HashMap<String, String>()); } /** * @return A TestRun object that can be iterated to run the script step by * step. */ public TestRun start() { return testRunFactory.createTestRun(this); } /** * @param log Logger to log to. * @param webDriverFactory Factory for the WebDriver to use for playback. * @param webDriverConfig Configuration for the factory/WebDriver. * @return A TestRun object that can be iterated to run the script step by * step. */
public TestRun start(Log log, WebDriverFactory webDriverFactory, HashMap<String, String> webDriverConfig) {
SeleniumBuilder/SeInterpreter-Java
src/com/sebuilder/interpreter/factory/DataSourceFactory.java
// Path: src/com/sebuilder/interpreter/DataSource.java // public interface DataSource { // public List<Map<String, String>> getData(Map<String, String> config, File relativeTo); // }
import com.sebuilder.interpreter.DataSource; import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright 2014 Sauce Labs * * 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.sebuilder.interpreter.factory; /** * Factory for data sources. * @author zarkonnen */ public class DataSourceFactory { public static final String DEFAULT_DATA_SOURCE_PACKAGE = "com.sebuilder.interpreter.datasource"; private String customDataSourcePackage = null; public String getCustomDataSourcePackage() { return customDataSourcePackage; } /** Package from which the factory preferentially loads in data sources. */ public void setCustomDataSourcePackage(String customDataSourcePackage) { this.customDataSourcePackage = customDataSourcePackage; } /** * Lazily loaded map of data sources. */
// Path: src/com/sebuilder/interpreter/DataSource.java // public interface DataSource { // public List<Map<String, String>> getData(Map<String, String> config, File relativeTo); // } // Path: src/com/sebuilder/interpreter/factory/DataSourceFactory.java import com.sebuilder.interpreter.DataSource; import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright 2014 Sauce Labs * * 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.sebuilder.interpreter.factory; /** * Factory for data sources. * @author zarkonnen */ public class DataSourceFactory { public static final String DEFAULT_DATA_SOURCE_PACKAGE = "com.sebuilder.interpreter.datasource"; private String customDataSourcePackage = null; public String getCustomDataSourcePackage() { return customDataSourcePackage; } /** Package from which the factory preferentially loads in data sources. */ public void setCustomDataSourcePackage(String customDataSourcePackage) { this.customDataSourcePackage = customDataSourcePackage; } /** * Lazily loaded map of data sources. */
private final HashMap<String, DataSource> sourcesMap = new HashMap<String, DataSource>();
gauthierj/dsm-webapi-client
dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/search/SearchService.java
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/PaginationAndSorting.java // public class PaginationAndSorting { // // public static final PaginationAndSorting DEFAULT_PAGINATION_AND_SORTING = new PaginationAndSorting(0, -1, Sort.NAME, SortDirection.ASC); // // public enum Sort { // // NAME("name"), USER("user"), GROUP("group"), MTIME("mtime"), ATIME("atime"), CTIME("ctime"), CRTIME("crtime"), POSIX("posix"), SIZE("size"), TYPE("type"); // // private final String representation; // // Sort(String representation) { // this.representation = representation; // } // // public String getRepresentation() { // return representation; // } // } // // public enum SortDirection { // // ASC("asc"), DESC("desc"); // // private final String representation; // // SortDirection(String representation) { // this.representation = representation; // } // // public String getRepresentation() { // return representation; // } // } // // private final int offset; // private final int limit; // private final Sort sortBy; // private final SortDirection sortDirection; // // public PaginationAndSorting(int offset, int limit, Sort sortBy, SortDirection sortDirection) { // this.offset = offset; // this.limit = limit; // this.sortBy = sortBy; // this.sortDirection = sortDirection; // } // // public static PaginationAndSorting getDefaultPaginationAndSorting() { // return DEFAULT_PAGINATION_AND_SORTING; // } // // public int getOffset() { // return offset; // } // // public int getLimit() { // return limit; // } // // public Sort getSortBy() { // return sortBy; // } // // public SortDirection getSortDirection() { // return sortDirection; // } // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/File.java // public class File { // // private final String path; // private final String name; // private final boolean directory; // private final FileProperties properties; // private final List<File> children = new ArrayList<>(); // // @JsonCreator // public File( // @JsonProperty("path") String path, // @JsonProperty("name") String name, // @JsonProperty("isdir") boolean directory, // @JsonProperty("additional") FileProperties properties, // @JsonProperty("children") FileList children) { // this.path = path; // this.name = name; // this.directory = directory; // this.properties = properties; // if(children != null) { // this.children.addAll(children.getElements()); // } // } // // public String getPath() { // return path; // } // // public String getName() { // return name; // } // // public boolean isDirectory() { // return directory; // } // // public FileProperties getProperties() { // return properties; // } // // public List<File> getChildren() { // return Collections.unmodifiableList(children); // } // // public static class FileList extends PaginatedList<File> { // // public FileList(@JsonProperty("total") int total, // @JsonProperty("offset") int offset, // @JsonProperty("files") List<File> files) { // super(total, offset, files); // } // } // }
import com.github.gauthierj.dsm.webapi.client.filestation.common.PaginationAndSorting; import com.github.gauthierj.dsm.webapi.client.filestation.common.File; import java.util.List;
package com.github.gauthierj.dsm.webapi.client.filestation.search; public interface SearchService { String start(String searchedFolderPath, boolean recursive, SearchCriteria searchCriteria); boolean isFinished(String taskId);
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/PaginationAndSorting.java // public class PaginationAndSorting { // // public static final PaginationAndSorting DEFAULT_PAGINATION_AND_SORTING = new PaginationAndSorting(0, -1, Sort.NAME, SortDirection.ASC); // // public enum Sort { // // NAME("name"), USER("user"), GROUP("group"), MTIME("mtime"), ATIME("atime"), CTIME("ctime"), CRTIME("crtime"), POSIX("posix"), SIZE("size"), TYPE("type"); // // private final String representation; // // Sort(String representation) { // this.representation = representation; // } // // public String getRepresentation() { // return representation; // } // } // // public enum SortDirection { // // ASC("asc"), DESC("desc"); // // private final String representation; // // SortDirection(String representation) { // this.representation = representation; // } // // public String getRepresentation() { // return representation; // } // } // // private final int offset; // private final int limit; // private final Sort sortBy; // private final SortDirection sortDirection; // // public PaginationAndSorting(int offset, int limit, Sort sortBy, SortDirection sortDirection) { // this.offset = offset; // this.limit = limit; // this.sortBy = sortBy; // this.sortDirection = sortDirection; // } // // public static PaginationAndSorting getDefaultPaginationAndSorting() { // return DEFAULT_PAGINATION_AND_SORTING; // } // // public int getOffset() { // return offset; // } // // public int getLimit() { // return limit; // } // // public Sort getSortBy() { // return sortBy; // } // // public SortDirection getSortDirection() { // return sortDirection; // } // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/File.java // public class File { // // private final String path; // private final String name; // private final boolean directory; // private final FileProperties properties; // private final List<File> children = new ArrayList<>(); // // @JsonCreator // public File( // @JsonProperty("path") String path, // @JsonProperty("name") String name, // @JsonProperty("isdir") boolean directory, // @JsonProperty("additional") FileProperties properties, // @JsonProperty("children") FileList children) { // this.path = path; // this.name = name; // this.directory = directory; // this.properties = properties; // if(children != null) { // this.children.addAll(children.getElements()); // } // } // // public String getPath() { // return path; // } // // public String getName() { // return name; // } // // public boolean isDirectory() { // return directory; // } // // public FileProperties getProperties() { // return properties; // } // // public List<File> getChildren() { // return Collections.unmodifiableList(children); // } // // public static class FileList extends PaginatedList<File> { // // public FileList(@JsonProperty("total") int total, // @JsonProperty("offset") int offset, // @JsonProperty("files") List<File> files) { // super(total, offset, files); // } // } // } // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/search/SearchService.java import com.github.gauthierj.dsm.webapi.client.filestation.common.PaginationAndSorting; import com.github.gauthierj.dsm.webapi.client.filestation.common.File; import java.util.List; package com.github.gauthierj.dsm.webapi.client.filestation.search; public interface SearchService { String start(String searchedFolderPath, boolean recursive, SearchCriteria searchCriteria); boolean isFinished(String taskId);
SearchResult getResult(String taskId, PaginationAndSorting paginationAndSorting);
gauthierj/dsm-webapi-client
dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/search/SearchService.java
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/PaginationAndSorting.java // public class PaginationAndSorting { // // public static final PaginationAndSorting DEFAULT_PAGINATION_AND_SORTING = new PaginationAndSorting(0, -1, Sort.NAME, SortDirection.ASC); // // public enum Sort { // // NAME("name"), USER("user"), GROUP("group"), MTIME("mtime"), ATIME("atime"), CTIME("ctime"), CRTIME("crtime"), POSIX("posix"), SIZE("size"), TYPE("type"); // // private final String representation; // // Sort(String representation) { // this.representation = representation; // } // // public String getRepresentation() { // return representation; // } // } // // public enum SortDirection { // // ASC("asc"), DESC("desc"); // // private final String representation; // // SortDirection(String representation) { // this.representation = representation; // } // // public String getRepresentation() { // return representation; // } // } // // private final int offset; // private final int limit; // private final Sort sortBy; // private final SortDirection sortDirection; // // public PaginationAndSorting(int offset, int limit, Sort sortBy, SortDirection sortDirection) { // this.offset = offset; // this.limit = limit; // this.sortBy = sortBy; // this.sortDirection = sortDirection; // } // // public static PaginationAndSorting getDefaultPaginationAndSorting() { // return DEFAULT_PAGINATION_AND_SORTING; // } // // public int getOffset() { // return offset; // } // // public int getLimit() { // return limit; // } // // public Sort getSortBy() { // return sortBy; // } // // public SortDirection getSortDirection() { // return sortDirection; // } // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/File.java // public class File { // // private final String path; // private final String name; // private final boolean directory; // private final FileProperties properties; // private final List<File> children = new ArrayList<>(); // // @JsonCreator // public File( // @JsonProperty("path") String path, // @JsonProperty("name") String name, // @JsonProperty("isdir") boolean directory, // @JsonProperty("additional") FileProperties properties, // @JsonProperty("children") FileList children) { // this.path = path; // this.name = name; // this.directory = directory; // this.properties = properties; // if(children != null) { // this.children.addAll(children.getElements()); // } // } // // public String getPath() { // return path; // } // // public String getName() { // return name; // } // // public boolean isDirectory() { // return directory; // } // // public FileProperties getProperties() { // return properties; // } // // public List<File> getChildren() { // return Collections.unmodifiableList(children); // } // // public static class FileList extends PaginatedList<File> { // // public FileList(@JsonProperty("total") int total, // @JsonProperty("offset") int offset, // @JsonProperty("files") List<File> files) { // super(total, offset, files); // } // } // }
import com.github.gauthierj.dsm.webapi.client.filestation.common.PaginationAndSorting; import com.github.gauthierj.dsm.webapi.client.filestation.common.File; import java.util.List;
package com.github.gauthierj.dsm.webapi.client.filestation.search; public interface SearchService { String start(String searchedFolderPath, boolean recursive, SearchCriteria searchCriteria); boolean isFinished(String taskId); SearchResult getResult(String taskId, PaginationAndSorting paginationAndSorting);
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/PaginationAndSorting.java // public class PaginationAndSorting { // // public static final PaginationAndSorting DEFAULT_PAGINATION_AND_SORTING = new PaginationAndSorting(0, -1, Sort.NAME, SortDirection.ASC); // // public enum Sort { // // NAME("name"), USER("user"), GROUP("group"), MTIME("mtime"), ATIME("atime"), CTIME("ctime"), CRTIME("crtime"), POSIX("posix"), SIZE("size"), TYPE("type"); // // private final String representation; // // Sort(String representation) { // this.representation = representation; // } // // public String getRepresentation() { // return representation; // } // } // // public enum SortDirection { // // ASC("asc"), DESC("desc"); // // private final String representation; // // SortDirection(String representation) { // this.representation = representation; // } // // public String getRepresentation() { // return representation; // } // } // // private final int offset; // private final int limit; // private final Sort sortBy; // private final SortDirection sortDirection; // // public PaginationAndSorting(int offset, int limit, Sort sortBy, SortDirection sortDirection) { // this.offset = offset; // this.limit = limit; // this.sortBy = sortBy; // this.sortDirection = sortDirection; // } // // public static PaginationAndSorting getDefaultPaginationAndSorting() { // return DEFAULT_PAGINATION_AND_SORTING; // } // // public int getOffset() { // return offset; // } // // public int getLimit() { // return limit; // } // // public Sort getSortBy() { // return sortBy; // } // // public SortDirection getSortDirection() { // return sortDirection; // } // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/File.java // public class File { // // private final String path; // private final String name; // private final boolean directory; // private final FileProperties properties; // private final List<File> children = new ArrayList<>(); // // @JsonCreator // public File( // @JsonProperty("path") String path, // @JsonProperty("name") String name, // @JsonProperty("isdir") boolean directory, // @JsonProperty("additional") FileProperties properties, // @JsonProperty("children") FileList children) { // this.path = path; // this.name = name; // this.directory = directory; // this.properties = properties; // if(children != null) { // this.children.addAll(children.getElements()); // } // } // // public String getPath() { // return path; // } // // public String getName() { // return name; // } // // public boolean isDirectory() { // return directory; // } // // public FileProperties getProperties() { // return properties; // } // // public List<File> getChildren() { // return Collections.unmodifiableList(children); // } // // public static class FileList extends PaginatedList<File> { // // public FileList(@JsonProperty("total") int total, // @JsonProperty("offset") int offset, // @JsonProperty("files") List<File> files) { // super(total, offset, files); // } // } // } // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/search/SearchService.java import com.github.gauthierj.dsm.webapi.client.filestation.common.PaginationAndSorting; import com.github.gauthierj.dsm.webapi.client.filestation.common.File; import java.util.List; package com.github.gauthierj.dsm.webapi.client.filestation.search; public interface SearchService { String start(String searchedFolderPath, boolean recursive, SearchCriteria searchCriteria); boolean isFinished(String taskId); SearchResult getResult(String taskId, PaginationAndSorting paginationAndSorting);
List<File> getResult(String taskId);
gauthierj/dsm-webapi-client
dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/filestation/filelist/FileListServiceTest.java
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/File.java // public class File { // // private final String path; // private final String name; // private final boolean directory; // private final FileProperties properties; // private final List<File> children = new ArrayList<>(); // // @JsonCreator // public File( // @JsonProperty("path") String path, // @JsonProperty("name") String name, // @JsonProperty("isdir") boolean directory, // @JsonProperty("additional") FileProperties properties, // @JsonProperty("children") FileList children) { // this.path = path; // this.name = name; // this.directory = directory; // this.properties = properties; // if(children != null) { // this.children.addAll(children.getElements()); // } // } // // public String getPath() { // return path; // } // // public String getName() { // return name; // } // // public boolean isDirectory() { // return directory; // } // // public FileProperties getProperties() { // return properties; // } // // public List<File> getChildren() { // return Collections.unmodifiableList(children); // } // // public static class FileList extends PaginatedList<File> { // // public FileList(@JsonProperty("total") int total, // @JsonProperty("offset") int offset, // @JsonProperty("files") List<File> files) { // super(total, offset, files); // } // } // } // // Path: dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/AbstractTest.java // @RunWith(SpringJUnit4ClassRunner.class) // @ContextConfiguration(classes = TestConfiguration.class) // @TestPropertySource("classpath:application-test.properties") // @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) // public abstract class AbstractTest { // // private static final String FILE_RESOURCES_ROOT = "/file-resources"; // // @Value("${dsm.share}") // private String share; // // @Value("${dsm.share.mountPoint}") // private String shareMountPointPath; // // private Path shareMountPoint; // // @Before // public void setUp() throws URISyntaxException, IOException, InterruptedException { // shareMountPoint = Paths.get(shareMountPointPath); // Assert.assertTrue(Files.exists(shareMountPoint)); // Assert.assertTrue(Files.isWritable(shareMountPoint)); // createFileStructure(); // } // // @After // public void tearDown() throws IOException { // FileUtils.cleanDirectory(shareMountPoint.toFile()); // } // // public String getShare() { // return share; // } // // public String getShareRoot() { // return "/" + share; // } // // public Path getShareMountPoint() { // return shareMountPoint; // } // // private void createFileStructure() throws URISyntaxException, IOException, InterruptedException { // URL resource = AbstractTest.class.getResource(FILE_RESOURCES_ROOT); // Path fileResourcesRoot = Paths.get(resource.toURI()); // int i = 0; // while (i < 5) { // try { // FileUtils.copyDirectory(fileResourcesRoot.toFile(), shareMountPoint.toFile()); // i = 5; // } catch (IOException e) { // if (i < 4) { // Thread.sleep(1000 + i * i * 1000); // i++; // } else { // throw new IllegalStateException("Could not create file structure", e); // } // } // } // } // // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/exception/FileNotFoundException.java // public class FileNotFoundException extends DsmWebApiErrorException { // // private final String path; // // public FileNotFoundException(String path, DsmWebApiResponseError error) { // super("No such file or directory", error); // this.path = path; // } // // public FileNotFoundException(Throwable cause, String path) { // super("No such file or directory", cause, null); // this.path = path; // } // // public String getPath() { // return path; // } // }
import com.github.gauthierj.dsm.webapi.client.filestation.common.File; import com.github.gauthierj.dsm.webapi.client.AbstractTest; import com.github.gauthierj.dsm.webapi.client.filestation.exception.FileNotFoundException; import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import java.util.Arrays; import java.util.List;
package com.github.gauthierj.dsm.webapi.client.filestation.filelist; public class FileListServiceTest extends AbstractTest{ @Autowired FileListService fileListService; @Test public void testList() throws Exception {
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/File.java // public class File { // // private final String path; // private final String name; // private final boolean directory; // private final FileProperties properties; // private final List<File> children = new ArrayList<>(); // // @JsonCreator // public File( // @JsonProperty("path") String path, // @JsonProperty("name") String name, // @JsonProperty("isdir") boolean directory, // @JsonProperty("additional") FileProperties properties, // @JsonProperty("children") FileList children) { // this.path = path; // this.name = name; // this.directory = directory; // this.properties = properties; // if(children != null) { // this.children.addAll(children.getElements()); // } // } // // public String getPath() { // return path; // } // // public String getName() { // return name; // } // // public boolean isDirectory() { // return directory; // } // // public FileProperties getProperties() { // return properties; // } // // public List<File> getChildren() { // return Collections.unmodifiableList(children); // } // // public static class FileList extends PaginatedList<File> { // // public FileList(@JsonProperty("total") int total, // @JsonProperty("offset") int offset, // @JsonProperty("files") List<File> files) { // super(total, offset, files); // } // } // } // // Path: dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/AbstractTest.java // @RunWith(SpringJUnit4ClassRunner.class) // @ContextConfiguration(classes = TestConfiguration.class) // @TestPropertySource("classpath:application-test.properties") // @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) // public abstract class AbstractTest { // // private static final String FILE_RESOURCES_ROOT = "/file-resources"; // // @Value("${dsm.share}") // private String share; // // @Value("${dsm.share.mountPoint}") // private String shareMountPointPath; // // private Path shareMountPoint; // // @Before // public void setUp() throws URISyntaxException, IOException, InterruptedException { // shareMountPoint = Paths.get(shareMountPointPath); // Assert.assertTrue(Files.exists(shareMountPoint)); // Assert.assertTrue(Files.isWritable(shareMountPoint)); // createFileStructure(); // } // // @After // public void tearDown() throws IOException { // FileUtils.cleanDirectory(shareMountPoint.toFile()); // } // // public String getShare() { // return share; // } // // public String getShareRoot() { // return "/" + share; // } // // public Path getShareMountPoint() { // return shareMountPoint; // } // // private void createFileStructure() throws URISyntaxException, IOException, InterruptedException { // URL resource = AbstractTest.class.getResource(FILE_RESOURCES_ROOT); // Path fileResourcesRoot = Paths.get(resource.toURI()); // int i = 0; // while (i < 5) { // try { // FileUtils.copyDirectory(fileResourcesRoot.toFile(), shareMountPoint.toFile()); // i = 5; // } catch (IOException e) { // if (i < 4) { // Thread.sleep(1000 + i * i * 1000); // i++; // } else { // throw new IllegalStateException("Could not create file structure", e); // } // } // } // } // // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/exception/FileNotFoundException.java // public class FileNotFoundException extends DsmWebApiErrorException { // // private final String path; // // public FileNotFoundException(String path, DsmWebApiResponseError error) { // super("No such file or directory", error); // this.path = path; // } // // public FileNotFoundException(Throwable cause, String path) { // super("No such file or directory", cause, null); // this.path = path; // } // // public String getPath() { // return path; // } // } // Path: dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/filestation/filelist/FileListServiceTest.java import com.github.gauthierj.dsm.webapi.client.filestation.common.File; import com.github.gauthierj.dsm.webapi.client.AbstractTest; import com.github.gauthierj.dsm.webapi.client.filestation.exception.FileNotFoundException; import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import java.util.Arrays; import java.util.List; package com.github.gauthierj.dsm.webapi.client.filestation.filelist; public class FileListServiceTest extends AbstractTest{ @Autowired FileListService fileListService; @Test public void testList() throws Exception {
List<File> list = fileListService.list("/dsm-webapi-it");
gauthierj/dsm-webapi-client
dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/filestation/filelist/FileListServiceTest.java
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/File.java // public class File { // // private final String path; // private final String name; // private final boolean directory; // private final FileProperties properties; // private final List<File> children = new ArrayList<>(); // // @JsonCreator // public File( // @JsonProperty("path") String path, // @JsonProperty("name") String name, // @JsonProperty("isdir") boolean directory, // @JsonProperty("additional") FileProperties properties, // @JsonProperty("children") FileList children) { // this.path = path; // this.name = name; // this.directory = directory; // this.properties = properties; // if(children != null) { // this.children.addAll(children.getElements()); // } // } // // public String getPath() { // return path; // } // // public String getName() { // return name; // } // // public boolean isDirectory() { // return directory; // } // // public FileProperties getProperties() { // return properties; // } // // public List<File> getChildren() { // return Collections.unmodifiableList(children); // } // // public static class FileList extends PaginatedList<File> { // // public FileList(@JsonProperty("total") int total, // @JsonProperty("offset") int offset, // @JsonProperty("files") List<File> files) { // super(total, offset, files); // } // } // } // // Path: dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/AbstractTest.java // @RunWith(SpringJUnit4ClassRunner.class) // @ContextConfiguration(classes = TestConfiguration.class) // @TestPropertySource("classpath:application-test.properties") // @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) // public abstract class AbstractTest { // // private static final String FILE_RESOURCES_ROOT = "/file-resources"; // // @Value("${dsm.share}") // private String share; // // @Value("${dsm.share.mountPoint}") // private String shareMountPointPath; // // private Path shareMountPoint; // // @Before // public void setUp() throws URISyntaxException, IOException, InterruptedException { // shareMountPoint = Paths.get(shareMountPointPath); // Assert.assertTrue(Files.exists(shareMountPoint)); // Assert.assertTrue(Files.isWritable(shareMountPoint)); // createFileStructure(); // } // // @After // public void tearDown() throws IOException { // FileUtils.cleanDirectory(shareMountPoint.toFile()); // } // // public String getShare() { // return share; // } // // public String getShareRoot() { // return "/" + share; // } // // public Path getShareMountPoint() { // return shareMountPoint; // } // // private void createFileStructure() throws URISyntaxException, IOException, InterruptedException { // URL resource = AbstractTest.class.getResource(FILE_RESOURCES_ROOT); // Path fileResourcesRoot = Paths.get(resource.toURI()); // int i = 0; // while (i < 5) { // try { // FileUtils.copyDirectory(fileResourcesRoot.toFile(), shareMountPoint.toFile()); // i = 5; // } catch (IOException e) { // if (i < 4) { // Thread.sleep(1000 + i * i * 1000); // i++; // } else { // throw new IllegalStateException("Could not create file structure", e); // } // } // } // } // // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/exception/FileNotFoundException.java // public class FileNotFoundException extends DsmWebApiErrorException { // // private final String path; // // public FileNotFoundException(String path, DsmWebApiResponseError error) { // super("No such file or directory", error); // this.path = path; // } // // public FileNotFoundException(Throwable cause, String path) { // super("No such file or directory", cause, null); // this.path = path; // } // // public String getPath() { // return path; // } // }
import com.github.gauthierj.dsm.webapi.client.filestation.common.File; import com.github.gauthierj.dsm.webapi.client.AbstractTest; import com.github.gauthierj.dsm.webapi.client.filestation.exception.FileNotFoundException; import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import java.util.Arrays; import java.util.List;
package com.github.gauthierj.dsm.webapi.client.filestation.filelist; public class FileListServiceTest extends AbstractTest{ @Autowired FileListService fileListService; @Test public void testList() throws Exception { List<File> list = fileListService.list("/dsm-webapi-it"); Assert.assertEquals(3, list.size()); } @Test public void testGetFiles() { List<File> files = fileListService.getFiles(Arrays.asList("/dsm-webapi-it/test-1", "/dsm-webapi-it/test-text-file.txt")); Assert.assertEquals(2, files.size()); }
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/File.java // public class File { // // private final String path; // private final String name; // private final boolean directory; // private final FileProperties properties; // private final List<File> children = new ArrayList<>(); // // @JsonCreator // public File( // @JsonProperty("path") String path, // @JsonProperty("name") String name, // @JsonProperty("isdir") boolean directory, // @JsonProperty("additional") FileProperties properties, // @JsonProperty("children") FileList children) { // this.path = path; // this.name = name; // this.directory = directory; // this.properties = properties; // if(children != null) { // this.children.addAll(children.getElements()); // } // } // // public String getPath() { // return path; // } // // public String getName() { // return name; // } // // public boolean isDirectory() { // return directory; // } // // public FileProperties getProperties() { // return properties; // } // // public List<File> getChildren() { // return Collections.unmodifiableList(children); // } // // public static class FileList extends PaginatedList<File> { // // public FileList(@JsonProperty("total") int total, // @JsonProperty("offset") int offset, // @JsonProperty("files") List<File> files) { // super(total, offset, files); // } // } // } // // Path: dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/AbstractTest.java // @RunWith(SpringJUnit4ClassRunner.class) // @ContextConfiguration(classes = TestConfiguration.class) // @TestPropertySource("classpath:application-test.properties") // @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) // public abstract class AbstractTest { // // private static final String FILE_RESOURCES_ROOT = "/file-resources"; // // @Value("${dsm.share}") // private String share; // // @Value("${dsm.share.mountPoint}") // private String shareMountPointPath; // // private Path shareMountPoint; // // @Before // public void setUp() throws URISyntaxException, IOException, InterruptedException { // shareMountPoint = Paths.get(shareMountPointPath); // Assert.assertTrue(Files.exists(shareMountPoint)); // Assert.assertTrue(Files.isWritable(shareMountPoint)); // createFileStructure(); // } // // @After // public void tearDown() throws IOException { // FileUtils.cleanDirectory(shareMountPoint.toFile()); // } // // public String getShare() { // return share; // } // // public String getShareRoot() { // return "/" + share; // } // // public Path getShareMountPoint() { // return shareMountPoint; // } // // private void createFileStructure() throws URISyntaxException, IOException, InterruptedException { // URL resource = AbstractTest.class.getResource(FILE_RESOURCES_ROOT); // Path fileResourcesRoot = Paths.get(resource.toURI()); // int i = 0; // while (i < 5) { // try { // FileUtils.copyDirectory(fileResourcesRoot.toFile(), shareMountPoint.toFile()); // i = 5; // } catch (IOException e) { // if (i < 4) { // Thread.sleep(1000 + i * i * 1000); // i++; // } else { // throw new IllegalStateException("Could not create file structure", e); // } // } // } // } // // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/exception/FileNotFoundException.java // public class FileNotFoundException extends DsmWebApiErrorException { // // private final String path; // // public FileNotFoundException(String path, DsmWebApiResponseError error) { // super("No such file or directory", error); // this.path = path; // } // // public FileNotFoundException(Throwable cause, String path) { // super("No such file or directory", cause, null); // this.path = path; // } // // public String getPath() { // return path; // } // } // Path: dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/filestation/filelist/FileListServiceTest.java import com.github.gauthierj.dsm.webapi.client.filestation.common.File; import com.github.gauthierj.dsm.webapi.client.AbstractTest; import com.github.gauthierj.dsm.webapi.client.filestation.exception.FileNotFoundException; import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import java.util.Arrays; import java.util.List; package com.github.gauthierj.dsm.webapi.client.filestation.filelist; public class FileListServiceTest extends AbstractTest{ @Autowired FileListService fileListService; @Test public void testList() throws Exception { List<File> list = fileListService.list("/dsm-webapi-it"); Assert.assertEquals(3, list.size()); } @Test public void testGetFiles() { List<File> files = fileListService.getFiles(Arrays.asList("/dsm-webapi-it/test-1", "/dsm-webapi-it/test-text-file.txt")); Assert.assertEquals(2, files.size()); }
@Test(expected = FileNotFoundException.class)
gauthierj/dsm-webapi-client
dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/apiinfo/ApiInfoServiceImpl.java
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebapiResponse.java // public class DsmWebapiResponse<T> { // // private boolean success; // private T data; // private DsmWebApiResponseError error; // // @JsonCreator // public DsmWebapiResponse(@JsonProperty("success") boolean success, // @JsonProperty("data") T data, // @JsonProperty("error") DsmWebApiResponseError error) { // this.success = success; // this.data = data; // this.error = error; // } // // public boolean isSuccess() { // return success; // } // // public T getData() { // return data; // } // // public DsmWebApiResponseError getError() { // return error; // } // // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebApiResponseError.java // public class DsmWebApiResponseError { // // private final int code; // private final List<DsmWebApiResponseError> errors = new ArrayList<>(); // private final Map<String, String> details = new HashMap<>(); // // @JsonCreator // public DsmWebApiResponseError(@JsonProperty("code") int code, // @JsonProperty("errors") List<DsmWebApiResponseError> errors) { // this.code = code; // this.errors.addAll(ofNullable(errors).orElse(new ArrayList<>())); // } // // public int getCode() { // return code; // } // // public List<DsmWebApiResponseError> getErrors() { // return Collections.unmodifiableList(errors); // } // // public Map<String, String> getDetails() { // return Collections.unmodifiableMap(details); // } // // @JsonAnySetter // public void addDetail(String key, String value) { // this.details.put(key, value); // } // // public String getDetailValue(String key) { // return details.get(key); // } // // @Override // public String toString() { // return "DsmWebApiResponseError{" + // "code=" + code + // ", errors=" + errors + // ", details=" + details + // '}'; // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebapiClient.java // public interface DsmWebapiClient { // // <T extends DsmWebapiResponse<?>> T call(DsmWebapiRequest request, Class<T> responseType); // // <T extends DsmWebapiResponse<?>> T call(DsmWebapiRequest request, Class<T> responseType, ErrorHandler errorHandler); // // URI buildUri(DsmWebapiRequest request); // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebapiRequest.java // public class DsmWebapiRequest { // // private final String api; // private final String version; // private final String path; // private final String method; // private final Map<String, String> parameters = new HashMap<>(); // // public DsmWebapiRequest(String api, String version, String path, String method) { // this.api = api; // this.version = version; // this.path = path; // this.method = method; // } // // public String getApi() { // return api; // } // // public String getVersion() { // return version; // } // // public String getPath() { // return path; // } // // public String getMethod() { // return method; // } // // public Map<String, String> getParameters() { // return Collections.unmodifiableMap(parameters); // } // // public DsmWebapiRequest parameter(String key, String value) { // this.parameters.put(key, value); // return this; // } // // public DsmWebapiRequest parameter(String key, Object value) { // this.parameters.put(key, value.toString()); // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value, Function<T, String> toString) { // if(value.isPresent()) { // this.parameter(key, toString.apply(value.get())); // } // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value) { // return this.optionalParameter(key, value, T::toString); // } // // public <T> DsmWebapiRequest optionalParameter(String key, T value, Predicate<T> shouldAdd) { // if(shouldAdd.test(value)) { // this.parameter(key, value); // } // return this; // } // // public DsmWebapiRequest optionalStringParameter(String key, String value) { // return this.optionalParameter(key, value, s -> !Strings.isNullOrEmpty(value)); // } // }
import com.fasterxml.jackson.annotation.JsonProperty; import com.github.gauthierj.dsm.webapi.client.DsmWebapiResponse; import com.github.gauthierj.dsm.webapi.client.DsmWebApiResponseError; import com.github.gauthierj.dsm.webapi.client.DsmWebapiClient; import com.github.gauthierj.dsm.webapi.client.DsmWebapiRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import java.util.List;
package com.github.gauthierj.dsm.webapi.client.apiinfo; @Component public class ApiInfoServiceImpl implements ApiInfoService { private static final String FILESTATION_INFO_API = "SYNO.API.Info"; private static final String FILESTATION_INFO_API_VERSION = "1"; private static final String FILESTATION_INFO_API_PATH = "query.cgi"; private static final String FILESTATION_INFO_API_LIST_METHOD = "query"; private static final String ALL_FILES_PARAMETERS = "all"; private static final String FILES_PARAMETERS = "query"; @Autowired @Qualifier("unauthenticated")
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebapiResponse.java // public class DsmWebapiResponse<T> { // // private boolean success; // private T data; // private DsmWebApiResponseError error; // // @JsonCreator // public DsmWebapiResponse(@JsonProperty("success") boolean success, // @JsonProperty("data") T data, // @JsonProperty("error") DsmWebApiResponseError error) { // this.success = success; // this.data = data; // this.error = error; // } // // public boolean isSuccess() { // return success; // } // // public T getData() { // return data; // } // // public DsmWebApiResponseError getError() { // return error; // } // // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebApiResponseError.java // public class DsmWebApiResponseError { // // private final int code; // private final List<DsmWebApiResponseError> errors = new ArrayList<>(); // private final Map<String, String> details = new HashMap<>(); // // @JsonCreator // public DsmWebApiResponseError(@JsonProperty("code") int code, // @JsonProperty("errors") List<DsmWebApiResponseError> errors) { // this.code = code; // this.errors.addAll(ofNullable(errors).orElse(new ArrayList<>())); // } // // public int getCode() { // return code; // } // // public List<DsmWebApiResponseError> getErrors() { // return Collections.unmodifiableList(errors); // } // // public Map<String, String> getDetails() { // return Collections.unmodifiableMap(details); // } // // @JsonAnySetter // public void addDetail(String key, String value) { // this.details.put(key, value); // } // // public String getDetailValue(String key) { // return details.get(key); // } // // @Override // public String toString() { // return "DsmWebApiResponseError{" + // "code=" + code + // ", errors=" + errors + // ", details=" + details + // '}'; // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebapiClient.java // public interface DsmWebapiClient { // // <T extends DsmWebapiResponse<?>> T call(DsmWebapiRequest request, Class<T> responseType); // // <T extends DsmWebapiResponse<?>> T call(DsmWebapiRequest request, Class<T> responseType, ErrorHandler errorHandler); // // URI buildUri(DsmWebapiRequest request); // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebapiRequest.java // public class DsmWebapiRequest { // // private final String api; // private final String version; // private final String path; // private final String method; // private final Map<String, String> parameters = new HashMap<>(); // // public DsmWebapiRequest(String api, String version, String path, String method) { // this.api = api; // this.version = version; // this.path = path; // this.method = method; // } // // public String getApi() { // return api; // } // // public String getVersion() { // return version; // } // // public String getPath() { // return path; // } // // public String getMethod() { // return method; // } // // public Map<String, String> getParameters() { // return Collections.unmodifiableMap(parameters); // } // // public DsmWebapiRequest parameter(String key, String value) { // this.parameters.put(key, value); // return this; // } // // public DsmWebapiRequest parameter(String key, Object value) { // this.parameters.put(key, value.toString()); // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value, Function<T, String> toString) { // if(value.isPresent()) { // this.parameter(key, toString.apply(value.get())); // } // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value) { // return this.optionalParameter(key, value, T::toString); // } // // public <T> DsmWebapiRequest optionalParameter(String key, T value, Predicate<T> shouldAdd) { // if(shouldAdd.test(value)) { // this.parameter(key, value); // } // return this; // } // // public DsmWebapiRequest optionalStringParameter(String key, String value) { // return this.optionalParameter(key, value, s -> !Strings.isNullOrEmpty(value)); // } // } // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/apiinfo/ApiInfoServiceImpl.java import com.fasterxml.jackson.annotation.JsonProperty; import com.github.gauthierj.dsm.webapi.client.DsmWebapiResponse; import com.github.gauthierj.dsm.webapi.client.DsmWebApiResponseError; import com.github.gauthierj.dsm.webapi.client.DsmWebapiClient; import com.github.gauthierj.dsm.webapi.client.DsmWebapiRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import java.util.List; package com.github.gauthierj.dsm.webapi.client.apiinfo; @Component public class ApiInfoServiceImpl implements ApiInfoService { private static final String FILESTATION_INFO_API = "SYNO.API.Info"; private static final String FILESTATION_INFO_API_VERSION = "1"; private static final String FILESTATION_INFO_API_PATH = "query.cgi"; private static final String FILESTATION_INFO_API_LIST_METHOD = "query"; private static final String ALL_FILES_PARAMETERS = "all"; private static final String FILES_PARAMETERS = "query"; @Autowired @Qualifier("unauthenticated")
private DsmWebapiClient restClient;
gauthierj/dsm-webapi-client
dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/filestation/search/SearchServiceTest.java
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/File.java // public class File { // // private final String path; // private final String name; // private final boolean directory; // private final FileProperties properties; // private final List<File> children = new ArrayList<>(); // // @JsonCreator // public File( // @JsonProperty("path") String path, // @JsonProperty("name") String name, // @JsonProperty("isdir") boolean directory, // @JsonProperty("additional") FileProperties properties, // @JsonProperty("children") FileList children) { // this.path = path; // this.name = name; // this.directory = directory; // this.properties = properties; // if(children != null) { // this.children.addAll(children.getElements()); // } // } // // public String getPath() { // return path; // } // // public String getName() { // return name; // } // // public boolean isDirectory() { // return directory; // } // // public FileProperties getProperties() { // return properties; // } // // public List<File> getChildren() { // return Collections.unmodifiableList(children); // } // // public static class FileList extends PaginatedList<File> { // // public FileList(@JsonProperty("total") int total, // @JsonProperty("offset") int offset, // @JsonProperty("files") List<File> files) { // super(total, offset, files); // } // } // } // // Path: dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/AbstractTest.java // @RunWith(SpringJUnit4ClassRunner.class) // @ContextConfiguration(classes = TestConfiguration.class) // @TestPropertySource("classpath:application-test.properties") // @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) // public abstract class AbstractTest { // // private static final String FILE_RESOURCES_ROOT = "/file-resources"; // // @Value("${dsm.share}") // private String share; // // @Value("${dsm.share.mountPoint}") // private String shareMountPointPath; // // private Path shareMountPoint; // // @Before // public void setUp() throws URISyntaxException, IOException, InterruptedException { // shareMountPoint = Paths.get(shareMountPointPath); // Assert.assertTrue(Files.exists(shareMountPoint)); // Assert.assertTrue(Files.isWritable(shareMountPoint)); // createFileStructure(); // } // // @After // public void tearDown() throws IOException { // FileUtils.cleanDirectory(shareMountPoint.toFile()); // } // // public String getShare() { // return share; // } // // public String getShareRoot() { // return "/" + share; // } // // public Path getShareMountPoint() { // return shareMountPoint; // } // // private void createFileStructure() throws URISyntaxException, IOException, InterruptedException { // URL resource = AbstractTest.class.getResource(FILE_RESOURCES_ROOT); // Path fileResourcesRoot = Paths.get(resource.toURI()); // int i = 0; // while (i < 5) { // try { // FileUtils.copyDirectory(fileResourcesRoot.toFile(), shareMountPoint.toFile()); // i = 5; // } catch (IOException e) { // if (i < 4) { // Thread.sleep(1000 + i * i * 1000); // i++; // } else { // throw new IllegalStateException("Could not create file structure", e); // } // } // } // } // // }
import com.github.gauthierj.dsm.webapi.client.filestation.common.File; import com.github.gauthierj.dsm.webapi.client.AbstractTest; import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import java.util.List;
package com.github.gauthierj.dsm.webapi.client.filestation.search; public class SearchServiceTest extends AbstractTest { @Autowired private SearchService searchService; @Test public void testSearch() { SearchCriteria build = SearchCriteria.SearchCriteriaBuilder .create() .pattern("test") .build();
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/File.java // public class File { // // private final String path; // private final String name; // private final boolean directory; // private final FileProperties properties; // private final List<File> children = new ArrayList<>(); // // @JsonCreator // public File( // @JsonProperty("path") String path, // @JsonProperty("name") String name, // @JsonProperty("isdir") boolean directory, // @JsonProperty("additional") FileProperties properties, // @JsonProperty("children") FileList children) { // this.path = path; // this.name = name; // this.directory = directory; // this.properties = properties; // if(children != null) { // this.children.addAll(children.getElements()); // } // } // // public String getPath() { // return path; // } // // public String getName() { // return name; // } // // public boolean isDirectory() { // return directory; // } // // public FileProperties getProperties() { // return properties; // } // // public List<File> getChildren() { // return Collections.unmodifiableList(children); // } // // public static class FileList extends PaginatedList<File> { // // public FileList(@JsonProperty("total") int total, // @JsonProperty("offset") int offset, // @JsonProperty("files") List<File> files) { // super(total, offset, files); // } // } // } // // Path: dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/AbstractTest.java // @RunWith(SpringJUnit4ClassRunner.class) // @ContextConfiguration(classes = TestConfiguration.class) // @TestPropertySource("classpath:application-test.properties") // @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) // public abstract class AbstractTest { // // private static final String FILE_RESOURCES_ROOT = "/file-resources"; // // @Value("${dsm.share}") // private String share; // // @Value("${dsm.share.mountPoint}") // private String shareMountPointPath; // // private Path shareMountPoint; // // @Before // public void setUp() throws URISyntaxException, IOException, InterruptedException { // shareMountPoint = Paths.get(shareMountPointPath); // Assert.assertTrue(Files.exists(shareMountPoint)); // Assert.assertTrue(Files.isWritable(shareMountPoint)); // createFileStructure(); // } // // @After // public void tearDown() throws IOException { // FileUtils.cleanDirectory(shareMountPoint.toFile()); // } // // public String getShare() { // return share; // } // // public String getShareRoot() { // return "/" + share; // } // // public Path getShareMountPoint() { // return shareMountPoint; // } // // private void createFileStructure() throws URISyntaxException, IOException, InterruptedException { // URL resource = AbstractTest.class.getResource(FILE_RESOURCES_ROOT); // Path fileResourcesRoot = Paths.get(resource.toURI()); // int i = 0; // while (i < 5) { // try { // FileUtils.copyDirectory(fileResourcesRoot.toFile(), shareMountPoint.toFile()); // i = 5; // } catch (IOException e) { // if (i < 4) { // Thread.sleep(1000 + i * i * 1000); // i++; // } else { // throw new IllegalStateException("Could not create file structure", e); // } // } // } // } // // } // Path: dsm-webapi-client-integration-tests/src/test/java/com/github/gauthierj/dsm/webapi/client/filestation/search/SearchServiceTest.java import com.github.gauthierj.dsm.webapi.client.filestation.common.File; import com.github.gauthierj.dsm.webapi.client.AbstractTest; import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import java.util.List; package com.github.gauthierj.dsm.webapi.client.filestation.search; public class SearchServiceTest extends AbstractTest { @Autowired private SearchService searchService; @Test public void testSearch() { SearchCriteria build = SearchCriteria.SearchCriteriaBuilder .create() .pattern("test") .build();
List<File> files = searchService.synchronousSearch("/dsm-webapi-it", true, build);
gauthierj/dsm-webapi-client
dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/copymove/CopyMoveService.java
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/OverwriteBehavior.java // public enum OverwriteBehavior { // OVERWRITE, SKIP, ERROR // }
import com.github.gauthierj.dsm.webapi.client.filestation.common.OverwriteBehavior; import org.springframework.stereotype.Service; import java.util.Optional;
package com.github.gauthierj.dsm.webapi.client.filestation.copymove; @Service public interface CopyMoveService {
// Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/common/OverwriteBehavior.java // public enum OverwriteBehavior { // OVERWRITE, SKIP, ERROR // } // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/copymove/CopyMoveService.java import com.github.gauthierj.dsm.webapi.client.filestation.common.OverwriteBehavior; import org.springframework.stereotype.Service; import java.util.Optional; package com.github.gauthierj.dsm.webapi.client.filestation.copymove; @Service public interface CopyMoveService {
String startCopy(String path, String destinationFolderPath, OverwriteBehavior overwriteBehavior);
gauthierj/dsm-webapi-client
dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/AbstractDsmServiceImpl.java
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/apiinfo/ApiInfo.java // public class ApiInfo { // // private final String api; // private final String minVersion; // private final String maxVersion; // private final String path; // private final String requestFormat; // // public ApiInfo(String api, String minVersion, String maxVersion, String path, String requestFormat) { // this.api = api; // this.minVersion = minVersion; // this.maxVersion = maxVersion; // this.path = path.replaceAll("^_+", "").trim(); // this.requestFormat = requestFormat; // } // // private ApiInfo(String api, ApiInfo source) { // this(api, source.getMinVersion(), source.getMaxVersion(), source.getPath(), source.getRequestFormat()); // } // // @JsonCreator // public ApiInfo( // @JsonProperty("minVersion") String minVersion, // @JsonProperty("maxVersion") String maxVersion, // @JsonProperty("path") String path, // @JsonProperty("requestFormat") String requestFormat) { // this(null, minVersion, maxVersion, path, requestFormat); // } // // public String getApi() { // return api; // } // // public String getMinVersion() { // return minVersion; // } // // public String getMaxVersion() { // return maxVersion; // } // // public String getPath() { // return path; // } // // public String getRequestFormat() { // return requestFormat; // } // // public static class ApiInfoList { // // private final List<ApiInfo> apiInfos = new ArrayList<>(); // // @JsonAnySetter // public void add(String key, ApiInfo value) { // apiInfos.add(new ApiInfo(key, value)); // } // // public List<ApiInfo> getApiInfos() { // return Collections.unmodifiableList(apiInfos); // } // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/apiinfo/ApiInfoService.java // public interface ApiInfoService { // List<ApiInfo> findAll(); // // ApiInfo findOne(String api); // }
import com.github.gauthierj.dsm.webapi.client.apiinfo.ApiInfo; import com.github.gauthierj.dsm.webapi.client.apiinfo.ApiInfoService; import org.springframework.beans.factory.annotation.Autowired; import javax.annotation.PostConstruct;
package com.github.gauthierj.dsm.webapi.client; public abstract class AbstractDsmServiceImpl { @Autowired
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/apiinfo/ApiInfo.java // public class ApiInfo { // // private final String api; // private final String minVersion; // private final String maxVersion; // private final String path; // private final String requestFormat; // // public ApiInfo(String api, String minVersion, String maxVersion, String path, String requestFormat) { // this.api = api; // this.minVersion = minVersion; // this.maxVersion = maxVersion; // this.path = path.replaceAll("^_+", "").trim(); // this.requestFormat = requestFormat; // } // // private ApiInfo(String api, ApiInfo source) { // this(api, source.getMinVersion(), source.getMaxVersion(), source.getPath(), source.getRequestFormat()); // } // // @JsonCreator // public ApiInfo( // @JsonProperty("minVersion") String minVersion, // @JsonProperty("maxVersion") String maxVersion, // @JsonProperty("path") String path, // @JsonProperty("requestFormat") String requestFormat) { // this(null, minVersion, maxVersion, path, requestFormat); // } // // public String getApi() { // return api; // } // // public String getMinVersion() { // return minVersion; // } // // public String getMaxVersion() { // return maxVersion; // } // // public String getPath() { // return path; // } // // public String getRequestFormat() { // return requestFormat; // } // // public static class ApiInfoList { // // private final List<ApiInfo> apiInfos = new ArrayList<>(); // // @JsonAnySetter // public void add(String key, ApiInfo value) { // apiInfos.add(new ApiInfo(key, value)); // } // // public List<ApiInfo> getApiInfos() { // return Collections.unmodifiableList(apiInfos); // } // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/apiinfo/ApiInfoService.java // public interface ApiInfoService { // List<ApiInfo> findAll(); // // ApiInfo findOne(String api); // } // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/AbstractDsmServiceImpl.java import com.github.gauthierj.dsm.webapi.client.apiinfo.ApiInfo; import com.github.gauthierj.dsm.webapi.client.apiinfo.ApiInfoService; import org.springframework.beans.factory.annotation.Autowired; import javax.annotation.PostConstruct; package com.github.gauthierj.dsm.webapi.client; public abstract class AbstractDsmServiceImpl { @Autowired
private ApiInfoService apiInfoService;
gauthierj/dsm-webapi-client
dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/AbstractDsmServiceImpl.java
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/apiinfo/ApiInfo.java // public class ApiInfo { // // private final String api; // private final String minVersion; // private final String maxVersion; // private final String path; // private final String requestFormat; // // public ApiInfo(String api, String minVersion, String maxVersion, String path, String requestFormat) { // this.api = api; // this.minVersion = minVersion; // this.maxVersion = maxVersion; // this.path = path.replaceAll("^_+", "").trim(); // this.requestFormat = requestFormat; // } // // private ApiInfo(String api, ApiInfo source) { // this(api, source.getMinVersion(), source.getMaxVersion(), source.getPath(), source.getRequestFormat()); // } // // @JsonCreator // public ApiInfo( // @JsonProperty("minVersion") String minVersion, // @JsonProperty("maxVersion") String maxVersion, // @JsonProperty("path") String path, // @JsonProperty("requestFormat") String requestFormat) { // this(null, minVersion, maxVersion, path, requestFormat); // } // // public String getApi() { // return api; // } // // public String getMinVersion() { // return minVersion; // } // // public String getMaxVersion() { // return maxVersion; // } // // public String getPath() { // return path; // } // // public String getRequestFormat() { // return requestFormat; // } // // public static class ApiInfoList { // // private final List<ApiInfo> apiInfos = new ArrayList<>(); // // @JsonAnySetter // public void add(String key, ApiInfo value) { // apiInfos.add(new ApiInfo(key, value)); // } // // public List<ApiInfo> getApiInfos() { // return Collections.unmodifiableList(apiInfos); // } // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/apiinfo/ApiInfoService.java // public interface ApiInfoService { // List<ApiInfo> findAll(); // // ApiInfo findOne(String api); // }
import com.github.gauthierj.dsm.webapi.client.apiinfo.ApiInfo; import com.github.gauthierj.dsm.webapi.client.apiinfo.ApiInfoService; import org.springframework.beans.factory.annotation.Autowired; import javax.annotation.PostConstruct;
package com.github.gauthierj.dsm.webapi.client; public abstract class AbstractDsmServiceImpl { @Autowired private ApiInfoService apiInfoService; @Autowired private DsmWebapiClient dsmWebapiClient; private final String apiId;
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/apiinfo/ApiInfo.java // public class ApiInfo { // // private final String api; // private final String minVersion; // private final String maxVersion; // private final String path; // private final String requestFormat; // // public ApiInfo(String api, String minVersion, String maxVersion, String path, String requestFormat) { // this.api = api; // this.minVersion = minVersion; // this.maxVersion = maxVersion; // this.path = path.replaceAll("^_+", "").trim(); // this.requestFormat = requestFormat; // } // // private ApiInfo(String api, ApiInfo source) { // this(api, source.getMinVersion(), source.getMaxVersion(), source.getPath(), source.getRequestFormat()); // } // // @JsonCreator // public ApiInfo( // @JsonProperty("minVersion") String minVersion, // @JsonProperty("maxVersion") String maxVersion, // @JsonProperty("path") String path, // @JsonProperty("requestFormat") String requestFormat) { // this(null, minVersion, maxVersion, path, requestFormat); // } // // public String getApi() { // return api; // } // // public String getMinVersion() { // return minVersion; // } // // public String getMaxVersion() { // return maxVersion; // } // // public String getPath() { // return path; // } // // public String getRequestFormat() { // return requestFormat; // } // // public static class ApiInfoList { // // private final List<ApiInfo> apiInfos = new ArrayList<>(); // // @JsonAnySetter // public void add(String key, ApiInfo value) { // apiInfos.add(new ApiInfo(key, value)); // } // // public List<ApiInfo> getApiInfos() { // return Collections.unmodifiableList(apiInfos); // } // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/apiinfo/ApiInfoService.java // public interface ApiInfoService { // List<ApiInfo> findAll(); // // ApiInfo findOne(String api); // } // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/AbstractDsmServiceImpl.java import com.github.gauthierj.dsm.webapi.client.apiinfo.ApiInfo; import com.github.gauthierj.dsm.webapi.client.apiinfo.ApiInfoService; import org.springframework.beans.factory.annotation.Autowired; import javax.annotation.PostConstruct; package com.github.gauthierj.dsm.webapi.client; public abstract class AbstractDsmServiceImpl { @Autowired private ApiInfoService apiInfoService; @Autowired private DsmWebapiClient dsmWebapiClient; private final String apiId;
private ApiInfo apiInfo;
gauthierj/dsm-webapi-client
dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/download/DownloadServiceImpl.java
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/AbstractDsmServiceImpl.java // public abstract class AbstractDsmServiceImpl { // // @Autowired // private ApiInfoService apiInfoService; // // @Autowired // private DsmWebapiClient dsmWebapiClient; // // private final String apiId; // // private ApiInfo apiInfo; // // public AbstractDsmServiceImpl(String apiId) { // this.apiId = apiId; // } // // @PostConstruct // public final void init() { // apiInfo = apiInfoService.findOne(apiId); // } // // public DsmWebapiClient getDsmWebapiClient() { // return dsmWebapiClient; // } // // public ApiInfoService getApiInfoService() { // return apiInfoService; // } // // public String getApiId() { // return apiId; // } // // public ApiInfo getApiInfo() { // return apiInfo; // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebapiRequest.java // public class DsmWebapiRequest { // // private final String api; // private final String version; // private final String path; // private final String method; // private final Map<String, String> parameters = new HashMap<>(); // // public DsmWebapiRequest(String api, String version, String path, String method) { // this.api = api; // this.version = version; // this.path = path; // this.method = method; // } // // public String getApi() { // return api; // } // // public String getVersion() { // return version; // } // // public String getPath() { // return path; // } // // public String getMethod() { // return method; // } // // public Map<String, String> getParameters() { // return Collections.unmodifiableMap(parameters); // } // // public DsmWebapiRequest parameter(String key, String value) { // this.parameters.put(key, value); // return this; // } // // public DsmWebapiRequest parameter(String key, Object value) { // this.parameters.put(key, value.toString()); // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value, Function<T, String> toString) { // if(value.isPresent()) { // this.parameter(key, toString.apply(value.get())); // } // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value) { // return this.optionalParameter(key, value, T::toString); // } // // public <T> DsmWebapiRequest optionalParameter(String key, T value, Predicate<T> shouldAdd) { // if(shouldAdd.test(value)) { // this.parameter(key, value); // } // return this; // } // // public DsmWebapiRequest optionalStringParameter(String key, String value) { // return this.optionalParameter(key, value, s -> !Strings.isNullOrEmpty(value)); // } // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/exception/FileNotFoundException.java // public class FileNotFoundException extends DsmWebApiErrorException { // // private final String path; // // public FileNotFoundException(String path, DsmWebApiResponseError error) { // super("No such file or directory", error); // this.path = path; // } // // public FileNotFoundException(Throwable cause, String path) { // super("No such file or directory", cause, null); // this.path = path; // } // // public String getPath() { // return path; // } // }
import com.github.gauthierj.dsm.webapi.client.AbstractDsmServiceImpl; import com.github.gauthierj.dsm.webapi.client.DsmWebapiRequest; import com.github.gauthierj.dsm.webapi.client.filestation.exception.FileNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import java.net.URI;
package com.github.gauthierj.dsm.webapi.client.filestation.download; @Component public class DownloadServiceImpl extends AbstractDsmServiceImpl implements DownloadService { // API Infos private static final String API_ID = "SYNO.FileStation.Download"; private static final String API_VERSION = "1"; // API Methods private static final String METHOD_DOWNLOAD = "download"; // Parameters private static final String PARAMETER_MODE = "mode"; private static final String PARAMETER_PATH = "path"; // Parameters values private static final String PARAMETER_VALUE_OPEN = "open"; @Autowired @Qualifier("downloadRestTemplate") private RestTemplate restTemplate; public DownloadServiceImpl() { super(API_ID); } @Override public byte[] download(String path) { try {
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/AbstractDsmServiceImpl.java // public abstract class AbstractDsmServiceImpl { // // @Autowired // private ApiInfoService apiInfoService; // // @Autowired // private DsmWebapiClient dsmWebapiClient; // // private final String apiId; // // private ApiInfo apiInfo; // // public AbstractDsmServiceImpl(String apiId) { // this.apiId = apiId; // } // // @PostConstruct // public final void init() { // apiInfo = apiInfoService.findOne(apiId); // } // // public DsmWebapiClient getDsmWebapiClient() { // return dsmWebapiClient; // } // // public ApiInfoService getApiInfoService() { // return apiInfoService; // } // // public String getApiId() { // return apiId; // } // // public ApiInfo getApiInfo() { // return apiInfo; // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebapiRequest.java // public class DsmWebapiRequest { // // private final String api; // private final String version; // private final String path; // private final String method; // private final Map<String, String> parameters = new HashMap<>(); // // public DsmWebapiRequest(String api, String version, String path, String method) { // this.api = api; // this.version = version; // this.path = path; // this.method = method; // } // // public String getApi() { // return api; // } // // public String getVersion() { // return version; // } // // public String getPath() { // return path; // } // // public String getMethod() { // return method; // } // // public Map<String, String> getParameters() { // return Collections.unmodifiableMap(parameters); // } // // public DsmWebapiRequest parameter(String key, String value) { // this.parameters.put(key, value); // return this; // } // // public DsmWebapiRequest parameter(String key, Object value) { // this.parameters.put(key, value.toString()); // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value, Function<T, String> toString) { // if(value.isPresent()) { // this.parameter(key, toString.apply(value.get())); // } // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value) { // return this.optionalParameter(key, value, T::toString); // } // // public <T> DsmWebapiRequest optionalParameter(String key, T value, Predicate<T> shouldAdd) { // if(shouldAdd.test(value)) { // this.parameter(key, value); // } // return this; // } // // public DsmWebapiRequest optionalStringParameter(String key, String value) { // return this.optionalParameter(key, value, s -> !Strings.isNullOrEmpty(value)); // } // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/exception/FileNotFoundException.java // public class FileNotFoundException extends DsmWebApiErrorException { // // private final String path; // // public FileNotFoundException(String path, DsmWebApiResponseError error) { // super("No such file or directory", error); // this.path = path; // } // // public FileNotFoundException(Throwable cause, String path) { // super("No such file or directory", cause, null); // this.path = path; // } // // public String getPath() { // return path; // } // } // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/download/DownloadServiceImpl.java import com.github.gauthierj.dsm.webapi.client.AbstractDsmServiceImpl; import com.github.gauthierj.dsm.webapi.client.DsmWebapiRequest; import com.github.gauthierj.dsm.webapi.client.filestation.exception.FileNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import java.net.URI; package com.github.gauthierj.dsm.webapi.client.filestation.download; @Component public class DownloadServiceImpl extends AbstractDsmServiceImpl implements DownloadService { // API Infos private static final String API_ID = "SYNO.FileStation.Download"; private static final String API_VERSION = "1"; // API Methods private static final String METHOD_DOWNLOAD = "download"; // Parameters private static final String PARAMETER_MODE = "mode"; private static final String PARAMETER_PATH = "path"; // Parameters values private static final String PARAMETER_VALUE_OPEN = "open"; @Autowired @Qualifier("downloadRestTemplate") private RestTemplate restTemplate; public DownloadServiceImpl() { super(API_ID); } @Override public byte[] download(String path) { try {
DsmWebapiRequest request = new DsmWebapiRequest(getApiInfo().getApi(), API_VERSION, getApiInfo().getPath(), METHOD_DOWNLOAD)
gauthierj/dsm-webapi-client
dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/download/DownloadServiceImpl.java
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/AbstractDsmServiceImpl.java // public abstract class AbstractDsmServiceImpl { // // @Autowired // private ApiInfoService apiInfoService; // // @Autowired // private DsmWebapiClient dsmWebapiClient; // // private final String apiId; // // private ApiInfo apiInfo; // // public AbstractDsmServiceImpl(String apiId) { // this.apiId = apiId; // } // // @PostConstruct // public final void init() { // apiInfo = apiInfoService.findOne(apiId); // } // // public DsmWebapiClient getDsmWebapiClient() { // return dsmWebapiClient; // } // // public ApiInfoService getApiInfoService() { // return apiInfoService; // } // // public String getApiId() { // return apiId; // } // // public ApiInfo getApiInfo() { // return apiInfo; // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebapiRequest.java // public class DsmWebapiRequest { // // private final String api; // private final String version; // private final String path; // private final String method; // private final Map<String, String> parameters = new HashMap<>(); // // public DsmWebapiRequest(String api, String version, String path, String method) { // this.api = api; // this.version = version; // this.path = path; // this.method = method; // } // // public String getApi() { // return api; // } // // public String getVersion() { // return version; // } // // public String getPath() { // return path; // } // // public String getMethod() { // return method; // } // // public Map<String, String> getParameters() { // return Collections.unmodifiableMap(parameters); // } // // public DsmWebapiRequest parameter(String key, String value) { // this.parameters.put(key, value); // return this; // } // // public DsmWebapiRequest parameter(String key, Object value) { // this.parameters.put(key, value.toString()); // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value, Function<T, String> toString) { // if(value.isPresent()) { // this.parameter(key, toString.apply(value.get())); // } // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value) { // return this.optionalParameter(key, value, T::toString); // } // // public <T> DsmWebapiRequest optionalParameter(String key, T value, Predicate<T> shouldAdd) { // if(shouldAdd.test(value)) { // this.parameter(key, value); // } // return this; // } // // public DsmWebapiRequest optionalStringParameter(String key, String value) { // return this.optionalParameter(key, value, s -> !Strings.isNullOrEmpty(value)); // } // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/exception/FileNotFoundException.java // public class FileNotFoundException extends DsmWebApiErrorException { // // private final String path; // // public FileNotFoundException(String path, DsmWebApiResponseError error) { // super("No such file or directory", error); // this.path = path; // } // // public FileNotFoundException(Throwable cause, String path) { // super("No such file or directory", cause, null); // this.path = path; // } // // public String getPath() { // return path; // } // }
import com.github.gauthierj.dsm.webapi.client.AbstractDsmServiceImpl; import com.github.gauthierj.dsm.webapi.client.DsmWebapiRequest; import com.github.gauthierj.dsm.webapi.client.filestation.exception.FileNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import java.net.URI;
package com.github.gauthierj.dsm.webapi.client.filestation.download; @Component public class DownloadServiceImpl extends AbstractDsmServiceImpl implements DownloadService { // API Infos private static final String API_ID = "SYNO.FileStation.Download"; private static final String API_VERSION = "1"; // API Methods private static final String METHOD_DOWNLOAD = "download"; // Parameters private static final String PARAMETER_MODE = "mode"; private static final String PARAMETER_PATH = "path"; // Parameters values private static final String PARAMETER_VALUE_OPEN = "open"; @Autowired @Qualifier("downloadRestTemplate") private RestTemplate restTemplate; public DownloadServiceImpl() { super(API_ID); } @Override public byte[] download(String path) { try { DsmWebapiRequest request = new DsmWebapiRequest(getApiInfo().getApi(), API_VERSION, getApiInfo().getPath(), METHOD_DOWNLOAD) .parameter(PARAMETER_PATH, path) .parameter(PARAMETER_MODE, PARAMETER_VALUE_OPEN); URI uri = getDsmWebapiClient().buildUri(request); ResponseEntity<byte[]> response = restTemplate.getForEntity(uri, byte[].class); return response.getBody(); } catch (HttpClientErrorException e) {
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/AbstractDsmServiceImpl.java // public abstract class AbstractDsmServiceImpl { // // @Autowired // private ApiInfoService apiInfoService; // // @Autowired // private DsmWebapiClient dsmWebapiClient; // // private final String apiId; // // private ApiInfo apiInfo; // // public AbstractDsmServiceImpl(String apiId) { // this.apiId = apiId; // } // // @PostConstruct // public final void init() { // apiInfo = apiInfoService.findOne(apiId); // } // // public DsmWebapiClient getDsmWebapiClient() { // return dsmWebapiClient; // } // // public ApiInfoService getApiInfoService() { // return apiInfoService; // } // // public String getApiId() { // return apiId; // } // // public ApiInfo getApiInfo() { // return apiInfo; // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebapiRequest.java // public class DsmWebapiRequest { // // private final String api; // private final String version; // private final String path; // private final String method; // private final Map<String, String> parameters = new HashMap<>(); // // public DsmWebapiRequest(String api, String version, String path, String method) { // this.api = api; // this.version = version; // this.path = path; // this.method = method; // } // // public String getApi() { // return api; // } // // public String getVersion() { // return version; // } // // public String getPath() { // return path; // } // // public String getMethod() { // return method; // } // // public Map<String, String> getParameters() { // return Collections.unmodifiableMap(parameters); // } // // public DsmWebapiRequest parameter(String key, String value) { // this.parameters.put(key, value); // return this; // } // // public DsmWebapiRequest parameter(String key, Object value) { // this.parameters.put(key, value.toString()); // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value, Function<T, String> toString) { // if(value.isPresent()) { // this.parameter(key, toString.apply(value.get())); // } // return this; // } // // public <T> DsmWebapiRequest optionalParameter(String key, Optional<T> value) { // return this.optionalParameter(key, value, T::toString); // } // // public <T> DsmWebapiRequest optionalParameter(String key, T value, Predicate<T> shouldAdd) { // if(shouldAdd.test(value)) { // this.parameter(key, value); // } // return this; // } // // public DsmWebapiRequest optionalStringParameter(String key, String value) { // return this.optionalParameter(key, value, s -> !Strings.isNullOrEmpty(value)); // } // } // // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/exception/FileNotFoundException.java // public class FileNotFoundException extends DsmWebApiErrorException { // // private final String path; // // public FileNotFoundException(String path, DsmWebApiResponseError error) { // super("No such file or directory", error); // this.path = path; // } // // public FileNotFoundException(Throwable cause, String path) { // super("No such file or directory", cause, null); // this.path = path; // } // // public String getPath() { // return path; // } // } // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/download/DownloadServiceImpl.java import com.github.gauthierj.dsm.webapi.client.AbstractDsmServiceImpl; import com.github.gauthierj.dsm.webapi.client.DsmWebapiRequest; import com.github.gauthierj.dsm.webapi.client.filestation.exception.FileNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import java.net.URI; package com.github.gauthierj.dsm.webapi.client.filestation.download; @Component public class DownloadServiceImpl extends AbstractDsmServiceImpl implements DownloadService { // API Infos private static final String API_ID = "SYNO.FileStation.Download"; private static final String API_VERSION = "1"; // API Methods private static final String METHOD_DOWNLOAD = "download"; // Parameters private static final String PARAMETER_MODE = "mode"; private static final String PARAMETER_PATH = "path"; // Parameters values private static final String PARAMETER_VALUE_OPEN = "open"; @Autowired @Qualifier("downloadRestTemplate") private RestTemplate restTemplate; public DownloadServiceImpl() { super(API_ID); } @Override public byte[] download(String path) { try { DsmWebapiRequest request = new DsmWebapiRequest(getApiInfo().getApi(), API_VERSION, getApiInfo().getPath(), METHOD_DOWNLOAD) .parameter(PARAMETER_PATH, path) .parameter(PARAMETER_MODE, PARAMETER_VALUE_OPEN); URI uri = getDsmWebapiClient().buildUri(request); ResponseEntity<byte[]> response = restTemplate.getForEntity(uri, byte[].class); return response.getBody(); } catch (HttpClientErrorException e) {
throw new FileNotFoundException(e, path);
gauthierj/dsm-webapi-client
dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/exception/CouldNotCreateFolderException.java
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebApiResponseError.java // public class DsmWebApiResponseError { // // private final int code; // private final List<DsmWebApiResponseError> errors = new ArrayList<>(); // private final Map<String, String> details = new HashMap<>(); // // @JsonCreator // public DsmWebApiResponseError(@JsonProperty("code") int code, // @JsonProperty("errors") List<DsmWebApiResponseError> errors) { // this.code = code; // this.errors.addAll(ofNullable(errors).orElse(new ArrayList<>())); // } // // public int getCode() { // return code; // } // // public List<DsmWebApiResponseError> getErrors() { // return Collections.unmodifiableList(errors); // } // // public Map<String, String> getDetails() { // return Collections.unmodifiableMap(details); // } // // @JsonAnySetter // public void addDetail(String key, String value) { // this.details.put(key, value); // } // // public String getDetailValue(String key) { // return details.get(key); // } // // @Override // public String toString() { // return "DsmWebApiResponseError{" + // "code=" + code + // ", errors=" + errors + // ", details=" + details + // '}'; // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/exception/DsmWebApiErrorException.java // public class DsmWebApiErrorException extends DsmWebApiClientException { // // private final DsmWebApiResponseError error; // // public DsmWebApiErrorException(String message, DsmWebApiResponseError error) { // super(message); // this.error = error; // } // // public DsmWebApiErrorException(String message, Throwable cause, DsmWebApiResponseError error) { // super(message, cause); // this.error = error; // } // // public DsmWebApiErrorException(Throwable cause, DsmWebApiResponseError error) { // super(cause); // this.error = error; // } // // public DsmWebApiResponseError getError() { // return error; // } // }
import com.github.gauthierj.dsm.webapi.client.DsmWebApiResponseError; import com.github.gauthierj.dsm.webapi.client.exception.DsmWebApiErrorException;
package com.github.gauthierj.dsm.webapi.client.filestation.exception; public class CouldNotCreateFolderException extends DsmWebApiErrorException { private final String parentPath; private final String name; private final boolean createParents;
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebApiResponseError.java // public class DsmWebApiResponseError { // // private final int code; // private final List<DsmWebApiResponseError> errors = new ArrayList<>(); // private final Map<String, String> details = new HashMap<>(); // // @JsonCreator // public DsmWebApiResponseError(@JsonProperty("code") int code, // @JsonProperty("errors") List<DsmWebApiResponseError> errors) { // this.code = code; // this.errors.addAll(ofNullable(errors).orElse(new ArrayList<>())); // } // // public int getCode() { // return code; // } // // public List<DsmWebApiResponseError> getErrors() { // return Collections.unmodifiableList(errors); // } // // public Map<String, String> getDetails() { // return Collections.unmodifiableMap(details); // } // // @JsonAnySetter // public void addDetail(String key, String value) { // this.details.put(key, value); // } // // public String getDetailValue(String key) { // return details.get(key); // } // // @Override // public String toString() { // return "DsmWebApiResponseError{" + // "code=" + code + // ", errors=" + errors + // ", details=" + details + // '}'; // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/exception/DsmWebApiErrorException.java // public class DsmWebApiErrorException extends DsmWebApiClientException { // // private final DsmWebApiResponseError error; // // public DsmWebApiErrorException(String message, DsmWebApiResponseError error) { // super(message); // this.error = error; // } // // public DsmWebApiErrorException(String message, Throwable cause, DsmWebApiResponseError error) { // super(message, cause); // this.error = error; // } // // public DsmWebApiErrorException(Throwable cause, DsmWebApiResponseError error) { // super(cause); // this.error = error; // } // // public DsmWebApiResponseError getError() { // return error; // } // } // Path: dsm-webapi-client-filestation/src/main/java/com/github/gauthierj/dsm/webapi/client/filestation/exception/CouldNotCreateFolderException.java import com.github.gauthierj.dsm.webapi.client.DsmWebApiResponseError; import com.github.gauthierj.dsm.webapi.client.exception.DsmWebApiErrorException; package com.github.gauthierj.dsm.webapi.client.filestation.exception; public class CouldNotCreateFolderException extends DsmWebApiErrorException { private final String parentPath; private final String name; private final boolean createParents;
public CouldNotCreateFolderException(String parentPath, String name, boolean createParents, DsmWebApiResponseError error) {
gauthierj/dsm-webapi-client
dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/authentication/exception/InvalidLoginException.java
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebApiResponseError.java // public class DsmWebApiResponseError { // // private final int code; // private final List<DsmWebApiResponseError> errors = new ArrayList<>(); // private final Map<String, String> details = new HashMap<>(); // // @JsonCreator // public DsmWebApiResponseError(@JsonProperty("code") int code, // @JsonProperty("errors") List<DsmWebApiResponseError> errors) { // this.code = code; // this.errors.addAll(ofNullable(errors).orElse(new ArrayList<>())); // } // // public int getCode() { // return code; // } // // public List<DsmWebApiResponseError> getErrors() { // return Collections.unmodifiableList(errors); // } // // public Map<String, String> getDetails() { // return Collections.unmodifiableMap(details); // } // // @JsonAnySetter // public void addDetail(String key, String value) { // this.details.put(key, value); // } // // public String getDetailValue(String key) { // return details.get(key); // } // // @Override // public String toString() { // return "DsmWebApiResponseError{" + // "code=" + code + // ", errors=" + errors + // ", details=" + details + // '}'; // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/exception/DsmWebApiErrorException.java // public class DsmWebApiErrorException extends DsmWebApiClientException { // // private final DsmWebApiResponseError error; // // public DsmWebApiErrorException(String message, DsmWebApiResponseError error) { // super(message); // this.error = error; // } // // public DsmWebApiErrorException(String message, Throwable cause, DsmWebApiResponseError error) { // super(message, cause); // this.error = error; // } // // public DsmWebApiErrorException(Throwable cause, DsmWebApiResponseError error) { // super(cause); // this.error = error; // } // // public DsmWebApiResponseError getError() { // return error; // } // }
import com.github.gauthierj.dsm.webapi.client.DsmWebApiResponseError; import com.github.gauthierj.dsm.webapi.client.exception.DsmWebApiErrorException;
package com.github.gauthierj.dsm.webapi.client.authentication.exception; public class InvalidLoginException extends DsmWebApiErrorException { public static final int ERROR_CODE_NO_SUCH_ACCOUNT = 400; public static final int ERROR_CODE_ACCOUNT_DISABLED = 401; public static final int ERROR_CODE_PERMISSION_DENIED = 402; public static final int ERROR_CODE_2_STEP_VERIFICATION_CODE_REQUIRED = 403; public static final int ERROR_CODE_2_STEP_VERIFICATION_CODE_AUTHENTICATION_FAILED = 404;
// Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/DsmWebApiResponseError.java // public class DsmWebApiResponseError { // // private final int code; // private final List<DsmWebApiResponseError> errors = new ArrayList<>(); // private final Map<String, String> details = new HashMap<>(); // // @JsonCreator // public DsmWebApiResponseError(@JsonProperty("code") int code, // @JsonProperty("errors") List<DsmWebApiResponseError> errors) { // this.code = code; // this.errors.addAll(ofNullable(errors).orElse(new ArrayList<>())); // } // // public int getCode() { // return code; // } // // public List<DsmWebApiResponseError> getErrors() { // return Collections.unmodifiableList(errors); // } // // public Map<String, String> getDetails() { // return Collections.unmodifiableMap(details); // } // // @JsonAnySetter // public void addDetail(String key, String value) { // this.details.put(key, value); // } // // public String getDetailValue(String key) { // return details.get(key); // } // // @Override // public String toString() { // return "DsmWebApiResponseError{" + // "code=" + code + // ", errors=" + errors + // ", details=" + details + // '}'; // } // } // // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/exception/DsmWebApiErrorException.java // public class DsmWebApiErrorException extends DsmWebApiClientException { // // private final DsmWebApiResponseError error; // // public DsmWebApiErrorException(String message, DsmWebApiResponseError error) { // super(message); // this.error = error; // } // // public DsmWebApiErrorException(String message, Throwable cause, DsmWebApiResponseError error) { // super(message, cause); // this.error = error; // } // // public DsmWebApiErrorException(Throwable cause, DsmWebApiResponseError error) { // super(cause); // this.error = error; // } // // public DsmWebApiResponseError getError() { // return error; // } // } // Path: dsm-webapi-client-core/src/main/java/com/github/gauthierj/dsm/webapi/client/authentication/exception/InvalidLoginException.java import com.github.gauthierj.dsm.webapi.client.DsmWebApiResponseError; import com.github.gauthierj.dsm.webapi.client.exception.DsmWebApiErrorException; package com.github.gauthierj.dsm.webapi.client.authentication.exception; public class InvalidLoginException extends DsmWebApiErrorException { public static final int ERROR_CODE_NO_SUCH_ACCOUNT = 400; public static final int ERROR_CODE_ACCOUNT_DISABLED = 401; public static final int ERROR_CODE_PERMISSION_DENIED = 402; public static final int ERROR_CODE_2_STEP_VERIFICATION_CODE_REQUIRED = 403; public static final int ERROR_CODE_2_STEP_VERIFICATION_CODE_AUTHENTICATION_FAILED = 404;
public InvalidLoginException(DsmWebApiResponseError error) {