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
|
|---|---|---|---|---|---|---|
statefulj/statefulj
|
statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/impl/FSMHarnessImpl.java
|
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/ContextWrapper.java
// public class ContextWrapper<CT> {
//
// private CT context;
//
// public ContextWrapper(CT context) {
// this.context = context;
// }
//
// public CT getContext() {
// return context;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/FSMHarness.java
// public interface FSMHarness {
//
// public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException;
//
// public Object onEvent(String event, Object[] parms) throws TooBusyException, InstantiationException;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Factory.java
// public interface Factory<T, CT> {
//
// /**
// * Called to create an instance of the StatefulEntity
// *
// * @param clazz The type of the StatefulEntity
// * @param event The incoming Event
// * @param context The Request Context
// * @return A new instance of the StatefulEntity
// */
// T create(Class<T> clazz, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Finder.java
// public interface Finder<T, CT> {
//
// /**
// * This find method is invoked when no Id can be determined from the input from the EndpointBinder.
// *
// * @param clazz The Class of the Stateful Event
// * @param event The Event
// * @param context The Request Context
// *
// * @return The Stateful Entity
// */
// T find(Class<T> clazz, String event, CT context);
//
// /**
// * @param clazz
// * @param id
// * @param event
// * @param context
// * @return
// */
// T find(Class<T> clazz, Object id, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
|
import java.util.ArrayList;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.statefulj.framework.core.fsm.ContextWrapper;
import org.statefulj.framework.core.model.FSMHarness;
import org.statefulj.framework.core.model.Factory;
import org.statefulj.framework.core.model.Finder;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
|
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.model.impl;
public class FSMHarnessImpl<T, CT> implements FSMHarness {
private static final Logger logger = LoggerFactory.getLogger(FSMHarnessImpl.class);
|
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/ContextWrapper.java
// public class ContextWrapper<CT> {
//
// private CT context;
//
// public ContextWrapper(CT context) {
// this.context = context;
// }
//
// public CT getContext() {
// return context;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/FSMHarness.java
// public interface FSMHarness {
//
// public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException;
//
// public Object onEvent(String event, Object[] parms) throws TooBusyException, InstantiationException;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Factory.java
// public interface Factory<T, CT> {
//
// /**
// * Called to create an instance of the StatefulEntity
// *
// * @param clazz The type of the StatefulEntity
// * @param event The incoming Event
// * @param context The Request Context
// * @return A new instance of the StatefulEntity
// */
// T create(Class<T> clazz, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Finder.java
// public interface Finder<T, CT> {
//
// /**
// * This find method is invoked when no Id can be determined from the input from the EndpointBinder.
// *
// * @param clazz The Class of the Stateful Event
// * @param event The Event
// * @param context The Request Context
// *
// * @return The Stateful Entity
// */
// T find(Class<T> clazz, String event, CT context);
//
// /**
// * @param clazz
// * @param id
// * @param event
// * @param context
// * @return
// */
// T find(Class<T> clazz, Object id, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/impl/FSMHarnessImpl.java
import java.util.ArrayList;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.statefulj.framework.core.fsm.ContextWrapper;
import org.statefulj.framework.core.model.FSMHarness;
import org.statefulj.framework.core.model.Factory;
import org.statefulj.framework.core.model.Finder;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.model.impl;
public class FSMHarnessImpl<T, CT> implements FSMHarness {
private static final Logger logger = LoggerFactory.getLogger(FSMHarnessImpl.class);
|
private Factory<T, CT> factory;
|
statefulj/statefulj
|
statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/impl/FSMHarnessImpl.java
|
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/ContextWrapper.java
// public class ContextWrapper<CT> {
//
// private CT context;
//
// public ContextWrapper(CT context) {
// this.context = context;
// }
//
// public CT getContext() {
// return context;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/FSMHarness.java
// public interface FSMHarness {
//
// public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException;
//
// public Object onEvent(String event, Object[] parms) throws TooBusyException, InstantiationException;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Factory.java
// public interface Factory<T, CT> {
//
// /**
// * Called to create an instance of the StatefulEntity
// *
// * @param clazz The type of the StatefulEntity
// * @param event The incoming Event
// * @param context The Request Context
// * @return A new instance of the StatefulEntity
// */
// T create(Class<T> clazz, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Finder.java
// public interface Finder<T, CT> {
//
// /**
// * This find method is invoked when no Id can be determined from the input from the EndpointBinder.
// *
// * @param clazz The Class of the Stateful Event
// * @param event The Event
// * @param context The Request Context
// *
// * @return The Stateful Entity
// */
// T find(Class<T> clazz, String event, CT context);
//
// /**
// * @param clazz
// * @param id
// * @param event
// * @param context
// * @return
// */
// T find(Class<T> clazz, Object id, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
|
import java.util.ArrayList;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.statefulj.framework.core.fsm.ContextWrapper;
import org.statefulj.framework.core.model.FSMHarness;
import org.statefulj.framework.core.model.Factory;
import org.statefulj.framework.core.model.Finder;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
|
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.model.impl;
public class FSMHarnessImpl<T, CT> implements FSMHarness {
private static final Logger logger = LoggerFactory.getLogger(FSMHarnessImpl.class);
private Factory<T, CT> factory;
|
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/ContextWrapper.java
// public class ContextWrapper<CT> {
//
// private CT context;
//
// public ContextWrapper(CT context) {
// this.context = context;
// }
//
// public CT getContext() {
// return context;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/FSMHarness.java
// public interface FSMHarness {
//
// public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException;
//
// public Object onEvent(String event, Object[] parms) throws TooBusyException, InstantiationException;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Factory.java
// public interface Factory<T, CT> {
//
// /**
// * Called to create an instance of the StatefulEntity
// *
// * @param clazz The type of the StatefulEntity
// * @param event The incoming Event
// * @param context The Request Context
// * @return A new instance of the StatefulEntity
// */
// T create(Class<T> clazz, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Finder.java
// public interface Finder<T, CT> {
//
// /**
// * This find method is invoked when no Id can be determined from the input from the EndpointBinder.
// *
// * @param clazz The Class of the Stateful Event
// * @param event The Event
// * @param context The Request Context
// *
// * @return The Stateful Entity
// */
// T find(Class<T> clazz, String event, CT context);
//
// /**
// * @param clazz
// * @param id
// * @param event
// * @param context
// * @return
// */
// T find(Class<T> clazz, Object id, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/impl/FSMHarnessImpl.java
import java.util.ArrayList;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.statefulj.framework.core.fsm.ContextWrapper;
import org.statefulj.framework.core.model.FSMHarness;
import org.statefulj.framework.core.model.Factory;
import org.statefulj.framework.core.model.Finder;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.model.impl;
public class FSMHarnessImpl<T, CT> implements FSMHarness {
private static final Logger logger = LoggerFactory.getLogger(FSMHarnessImpl.class);
private Factory<T, CT> factory;
|
private Finder<T, CT> finder;
|
statefulj/statefulj
|
statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/impl/FSMHarnessImpl.java
|
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/ContextWrapper.java
// public class ContextWrapper<CT> {
//
// private CT context;
//
// public ContextWrapper(CT context) {
// this.context = context;
// }
//
// public CT getContext() {
// return context;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/FSMHarness.java
// public interface FSMHarness {
//
// public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException;
//
// public Object onEvent(String event, Object[] parms) throws TooBusyException, InstantiationException;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Factory.java
// public interface Factory<T, CT> {
//
// /**
// * Called to create an instance of the StatefulEntity
// *
// * @param clazz The type of the StatefulEntity
// * @param event The incoming Event
// * @param context The Request Context
// * @return A new instance of the StatefulEntity
// */
// T create(Class<T> clazz, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Finder.java
// public interface Finder<T, CT> {
//
// /**
// * This find method is invoked when no Id can be determined from the input from the EndpointBinder.
// *
// * @param clazz The Class of the Stateful Event
// * @param event The Event
// * @param context The Request Context
// *
// * @return The Stateful Entity
// */
// T find(Class<T> clazz, String event, CT context);
//
// /**
// * @param clazz
// * @param id
// * @param event
// * @param context
// * @return
// */
// T find(Class<T> clazz, Object id, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
|
import java.util.ArrayList;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.statefulj.framework.core.fsm.ContextWrapper;
import org.statefulj.framework.core.model.FSMHarness;
import org.statefulj.framework.core.model.Factory;
import org.statefulj.framework.core.model.Finder;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
|
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.model.impl;
public class FSMHarnessImpl<T, CT> implements FSMHarness {
private static final Logger logger = LoggerFactory.getLogger(FSMHarnessImpl.class);
private Factory<T, CT> factory;
private Finder<T, CT> finder;
|
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/ContextWrapper.java
// public class ContextWrapper<CT> {
//
// private CT context;
//
// public ContextWrapper(CT context) {
// this.context = context;
// }
//
// public CT getContext() {
// return context;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/FSMHarness.java
// public interface FSMHarness {
//
// public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException;
//
// public Object onEvent(String event, Object[] parms) throws TooBusyException, InstantiationException;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Factory.java
// public interface Factory<T, CT> {
//
// /**
// * Called to create an instance of the StatefulEntity
// *
// * @param clazz The type of the StatefulEntity
// * @param event The incoming Event
// * @param context The Request Context
// * @return A new instance of the StatefulEntity
// */
// T create(Class<T> clazz, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Finder.java
// public interface Finder<T, CT> {
//
// /**
// * This find method is invoked when no Id can be determined from the input from the EndpointBinder.
// *
// * @param clazz The Class of the Stateful Event
// * @param event The Event
// * @param context The Request Context
// *
// * @return The Stateful Entity
// */
// T find(Class<T> clazz, String event, CT context);
//
// /**
// * @param clazz
// * @param id
// * @param event
// * @param context
// * @return
// */
// T find(Class<T> clazz, Object id, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/impl/FSMHarnessImpl.java
import java.util.ArrayList;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.statefulj.framework.core.fsm.ContextWrapper;
import org.statefulj.framework.core.model.FSMHarness;
import org.statefulj.framework.core.model.Factory;
import org.statefulj.framework.core.model.Finder;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.model.impl;
public class FSMHarnessImpl<T, CT> implements FSMHarness {
private static final Logger logger = LoggerFactory.getLogger(FSMHarnessImpl.class);
private Factory<T, CT> factory;
private Finder<T, CT> finder;
|
private StatefulFSM<T> fsm;
|
statefulj/statefulj
|
statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/impl/FSMHarnessImpl.java
|
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/ContextWrapper.java
// public class ContextWrapper<CT> {
//
// private CT context;
//
// public ContextWrapper(CT context) {
// this.context = context;
// }
//
// public CT getContext() {
// return context;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/FSMHarness.java
// public interface FSMHarness {
//
// public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException;
//
// public Object onEvent(String event, Object[] parms) throws TooBusyException, InstantiationException;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Factory.java
// public interface Factory<T, CT> {
//
// /**
// * Called to create an instance of the StatefulEntity
// *
// * @param clazz The type of the StatefulEntity
// * @param event The incoming Event
// * @param context The Request Context
// * @return A new instance of the StatefulEntity
// */
// T create(Class<T> clazz, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Finder.java
// public interface Finder<T, CT> {
//
// /**
// * This find method is invoked when no Id can be determined from the input from the EndpointBinder.
// *
// * @param clazz The Class of the Stateful Event
// * @param event The Event
// * @param context The Request Context
// *
// * @return The Stateful Entity
// */
// T find(Class<T> clazz, String event, CT context);
//
// /**
// * @param clazz
// * @param id
// * @param event
// * @param context
// * @return
// */
// T find(Class<T> clazz, Object id, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
|
import java.util.ArrayList;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.statefulj.framework.core.fsm.ContextWrapper;
import org.statefulj.framework.core.model.FSMHarness;
import org.statefulj.framework.core.model.Factory;
import org.statefulj.framework.core.model.Finder;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
|
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.model.impl;
public class FSMHarnessImpl<T, CT> implements FSMHarness {
private static final Logger logger = LoggerFactory.getLogger(FSMHarnessImpl.class);
private Factory<T, CT> factory;
private Finder<T, CT> finder;
private StatefulFSM<T> fsm;
private Class<T> clazz;
public FSMHarnessImpl(
StatefulFSM<T> fsm,
Class<T> clazz,
Factory<T, CT> factory,
Finder<T, CT> finder) {
this.fsm = fsm;
this.clazz = clazz;
this.factory = factory;
this.finder = finder;
}
@Override
@SuppressWarnings({ "unchecked" })
|
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/ContextWrapper.java
// public class ContextWrapper<CT> {
//
// private CT context;
//
// public ContextWrapper(CT context) {
// this.context = context;
// }
//
// public CT getContext() {
// return context;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/FSMHarness.java
// public interface FSMHarness {
//
// public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException;
//
// public Object onEvent(String event, Object[] parms) throws TooBusyException, InstantiationException;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Factory.java
// public interface Factory<T, CT> {
//
// /**
// * Called to create an instance of the StatefulEntity
// *
// * @param clazz The type of the StatefulEntity
// * @param event The incoming Event
// * @param context The Request Context
// * @return A new instance of the StatefulEntity
// */
// T create(Class<T> clazz, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Finder.java
// public interface Finder<T, CT> {
//
// /**
// * This find method is invoked when no Id can be determined from the input from the EndpointBinder.
// *
// * @param clazz The Class of the Stateful Event
// * @param event The Event
// * @param context The Request Context
// *
// * @return The Stateful Entity
// */
// T find(Class<T> clazz, String event, CT context);
//
// /**
// * @param clazz
// * @param id
// * @param event
// * @param context
// * @return
// */
// T find(Class<T> clazz, Object id, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/impl/FSMHarnessImpl.java
import java.util.ArrayList;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.statefulj.framework.core.fsm.ContextWrapper;
import org.statefulj.framework.core.model.FSMHarness;
import org.statefulj.framework.core.model.Factory;
import org.statefulj.framework.core.model.Finder;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.model.impl;
public class FSMHarnessImpl<T, CT> implements FSMHarness {
private static final Logger logger = LoggerFactory.getLogger(FSMHarnessImpl.class);
private Factory<T, CT> factory;
private Finder<T, CT> finder;
private StatefulFSM<T> fsm;
private Class<T> clazz;
public FSMHarnessImpl(
StatefulFSM<T> fsm,
Class<T> clazz,
Factory<T, CT> factory,
Finder<T, CT> finder) {
this.fsm = fsm;
this.clazz = clazz;
this.factory = factory;
this.finder = finder;
}
@Override
@SuppressWarnings({ "unchecked" })
|
public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException {
|
statefulj/statefulj
|
statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/impl/FSMHarnessImpl.java
|
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/ContextWrapper.java
// public class ContextWrapper<CT> {
//
// private CT context;
//
// public ContextWrapper(CT context) {
// this.context = context;
// }
//
// public CT getContext() {
// return context;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/FSMHarness.java
// public interface FSMHarness {
//
// public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException;
//
// public Object onEvent(String event, Object[] parms) throws TooBusyException, InstantiationException;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Factory.java
// public interface Factory<T, CT> {
//
// /**
// * Called to create an instance of the StatefulEntity
// *
// * @param clazz The type of the StatefulEntity
// * @param event The incoming Event
// * @param context The Request Context
// * @return A new instance of the StatefulEntity
// */
// T create(Class<T> clazz, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Finder.java
// public interface Finder<T, CT> {
//
// /**
// * This find method is invoked when no Id can be determined from the input from the EndpointBinder.
// *
// * @param clazz The Class of the Stateful Event
// * @param event The Event
// * @param context The Request Context
// *
// * @return The Stateful Entity
// */
// T find(Class<T> clazz, String event, CT context);
//
// /**
// * @param clazz
// * @param id
// * @param event
// * @param context
// * @return
// */
// T find(Class<T> clazz, Object id, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
|
import java.util.ArrayList;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.statefulj.framework.core.fsm.ContextWrapper;
import org.statefulj.framework.core.model.FSMHarness;
import org.statefulj.framework.core.model.Factory;
import org.statefulj.framework.core.model.Finder;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
|
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.model.impl;
public class FSMHarnessImpl<T, CT> implements FSMHarness {
private static final Logger logger = LoggerFactory.getLogger(FSMHarnessImpl.class);
private Factory<T, CT> factory;
private Finder<T, CT> finder;
private StatefulFSM<T> fsm;
private Class<T> clazz;
public FSMHarnessImpl(
StatefulFSM<T> fsm,
Class<T> clazz,
Factory<T, CT> factory,
Finder<T, CT> finder) {
this.fsm = fsm;
this.clazz = clazz;
this.factory = factory;
this.finder = finder;
}
@Override
@SuppressWarnings({ "unchecked" })
public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException {
ArrayList<Object> parmList = new ArrayList<Object>(Arrays.asList(parms));
CT context = (parmList.size() > 0) ? (CT)parmList.remove(0) : null;
|
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/ContextWrapper.java
// public class ContextWrapper<CT> {
//
// private CT context;
//
// public ContextWrapper(CT context) {
// this.context = context;
// }
//
// public CT getContext() {
// return context;
// }
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/FSMHarness.java
// public interface FSMHarness {
//
// public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException;
//
// public Object onEvent(String event, Object[] parms) throws TooBusyException, InstantiationException;
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Factory.java
// public interface Factory<T, CT> {
//
// /**
// * Called to create an instance of the StatefulEntity
// *
// * @param clazz The type of the StatefulEntity
// * @param event The incoming Event
// * @param context The Request Context
// * @return A new instance of the StatefulEntity
// */
// T create(Class<T> clazz, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/Finder.java
// public interface Finder<T, CT> {
//
// /**
// * This find method is invoked when no Id can be determined from the input from the EndpointBinder.
// *
// * @param clazz The Class of the Stateful Event
// * @param event The Event
// * @param context The Request Context
// *
// * @return The Stateful Entity
// */
// T find(Class<T> clazz, String event, CT context);
//
// /**
// * @param clazz
// * @param id
// * @param event
// * @param context
// * @return
// */
// T find(Class<T> clazz, Object id, String event, CT context);
//
// }
//
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/StatefulFSM.java
// public interface StatefulFSM<T> {
//
// /**
// * Pass an event to the FSM for a non-existent Stateful Entity. The StatefulJ framework will instiate a
// * new Stateful Event by invoking the {@link Factory}
// *
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(String event, Object... parms) throws TooBusyException ;
//
// /**
// * Pass an event to the FSM for existing Stateful Entity
// *
// * @param stateful the Stateful Entity
// * @param event the Event
// * @param parms Optional parameters passed into the Action method
// * @return the returned Object from the Action Method
// * @throws TooBusyException thrown if the FSM cannot process the event
// */
// Object onEvent(T stateful, String event, Object... parms) throws TooBusyException ;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/TooBusyException.java
// public class TooBusyException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/model/impl/FSMHarnessImpl.java
import java.util.ArrayList;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.statefulj.framework.core.fsm.ContextWrapper;
import org.statefulj.framework.core.model.FSMHarness;
import org.statefulj.framework.core.model.Factory;
import org.statefulj.framework.core.model.Finder;
import org.statefulj.framework.core.model.StatefulFSM;
import org.statefulj.fsm.TooBusyException;
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.model.impl;
public class FSMHarnessImpl<T, CT> implements FSMHarness {
private static final Logger logger = LoggerFactory.getLogger(FSMHarnessImpl.class);
private Factory<T, CT> factory;
private Finder<T, CT> finder;
private StatefulFSM<T> fsm;
private Class<T> clazz;
public FSMHarnessImpl(
StatefulFSM<T> fsm,
Class<T> clazz,
Factory<T, CT> factory,
Finder<T, CT> finder) {
this.fsm = fsm;
this.clazz = clazz;
this.factory = factory;
this.finder = finder;
}
@Override
@SuppressWarnings({ "unchecked" })
public Object onEvent(String event, Object id, Object[] parms) throws TooBusyException {
ArrayList<Object> parmList = new ArrayList<Object>(Arrays.asList(parms));
CT context = (parmList.size() > 0) ? (CT)parmList.remove(0) : null;
|
ContextWrapper<CT> retryParms = new ContextWrapper<CT>(context);
|
statefulj/statefulj
|
statefulj-persistence/statefulj-persistence-common/src/test/java/org/statefulj/persistence/common/AbstractPersisterTest.java
|
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
|
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import static org.junit.Assert.*;
import org.statefulj.fsm.model.State;
import static org.mockito.Mockito.*;
|
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.persistence.common;
public class AbstractPersisterTest {
@SuppressWarnings("unchecked")
@Test
public void testAlternateStateFields() {
|
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
// Path: statefulj-persistence/statefulj-persistence-common/src/test/java/org/statefulj/persistence/common/AbstractPersisterTest.java
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import static org.junit.Assert.*;
import org.statefulj.fsm.model.State;
import static org.mockito.Mockito.*;
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.persistence.common;
public class AbstractPersisterTest {
@SuppressWarnings("unchecked")
@Test
public void testAlternateStateFields() {
|
List<State<MockEntity>> states = new ArrayList<State<MockEntity>>();
|
statefulj/statefulj
|
statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/WaitAndRetryActionImpl.java
|
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/RetryException.java
// public class RetryException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public RetryException() {
// super();
// }
//
// public RetryException(String msg) {
// super(msg);
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/WaitAndRetryException.java
// public class WaitAndRetryException extends RetryException {
//
// private static final long serialVersionUID = 1L;
//
// private int wait;
//
// public WaitAndRetryException(int wait) {
// this.wait = wait;
// }
//
// public int getWait() {
// return wait;
// }
//
// public void setWait(int wait) {
// this.wait = wait;
// }
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
|
import org.statefulj.fsm.RetryException;
import org.statefulj.fsm.WaitAndRetryException;
import org.statefulj.fsm.model.Action;
|
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.fsm.model.impl;
/**
* Action with throws a {@link org.statefulj.fsm.WaitAndRetryException}
*
* @author Andrew Hall
*
* @param <T>
*/
public class WaitAndRetryActionImpl<T> implements Action<T> {
private int wait = 0;
/**
* Constructor with a wait time expressed in milliseconds
*
* @param wait time in milliseconds
*/
public WaitAndRetryActionImpl(int wait) {
this.wait = wait;
}
@Override
|
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/RetryException.java
// public class RetryException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public RetryException() {
// super();
// }
//
// public RetryException(String msg) {
// super(msg);
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/WaitAndRetryException.java
// public class WaitAndRetryException extends RetryException {
//
// private static final long serialVersionUID = 1L;
//
// private int wait;
//
// public WaitAndRetryException(int wait) {
// this.wait = wait;
// }
//
// public int getWait() {
// return wait;
// }
//
// public void setWait(int wait) {
// this.wait = wait;
// }
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/WaitAndRetryActionImpl.java
import org.statefulj.fsm.RetryException;
import org.statefulj.fsm.WaitAndRetryException;
import org.statefulj.fsm.model.Action;
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.fsm.model.impl;
/**
* Action with throws a {@link org.statefulj.fsm.WaitAndRetryException}
*
* @author Andrew Hall
*
* @param <T>
*/
public class WaitAndRetryActionImpl<T> implements Action<T> {
private int wait = 0;
/**
* Constructor with a wait time expressed in milliseconds
*
* @param wait time in milliseconds
*/
public WaitAndRetryActionImpl(int wait) {
this.wait = wait;
}
@Override
|
public void execute(T obj, String event, Object... args) throws RetryException {
|
statefulj/statefulj
|
statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/WaitAndRetryActionImpl.java
|
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/RetryException.java
// public class RetryException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public RetryException() {
// super();
// }
//
// public RetryException(String msg) {
// super(msg);
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/WaitAndRetryException.java
// public class WaitAndRetryException extends RetryException {
//
// private static final long serialVersionUID = 1L;
//
// private int wait;
//
// public WaitAndRetryException(int wait) {
// this.wait = wait;
// }
//
// public int getWait() {
// return wait;
// }
//
// public void setWait(int wait) {
// this.wait = wait;
// }
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
|
import org.statefulj.fsm.RetryException;
import org.statefulj.fsm.WaitAndRetryException;
import org.statefulj.fsm.model.Action;
|
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.fsm.model.impl;
/**
* Action with throws a {@link org.statefulj.fsm.WaitAndRetryException}
*
* @author Andrew Hall
*
* @param <T>
*/
public class WaitAndRetryActionImpl<T> implements Action<T> {
private int wait = 0;
/**
* Constructor with a wait time expressed in milliseconds
*
* @param wait time in milliseconds
*/
public WaitAndRetryActionImpl(int wait) {
this.wait = wait;
}
@Override
public void execute(T obj, String event, Object... args) throws RetryException {
|
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/RetryException.java
// public class RetryException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// public RetryException() {
// super();
// }
//
// public RetryException(String msg) {
// super(msg);
// }
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/WaitAndRetryException.java
// public class WaitAndRetryException extends RetryException {
//
// private static final long serialVersionUID = 1L;
//
// private int wait;
//
// public WaitAndRetryException(int wait) {
// this.wait = wait;
// }
//
// public int getWait() {
// return wait;
// }
//
// public void setWait(int wait) {
// this.wait = wait;
// }
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/WaitAndRetryActionImpl.java
import org.statefulj.fsm.RetryException;
import org.statefulj.fsm.WaitAndRetryException;
import org.statefulj.fsm.model.Action;
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.fsm.model.impl;
/**
* Action with throws a {@link org.statefulj.fsm.WaitAndRetryException}
*
* @author Andrew Hall
*
* @param <T>
*/
public class WaitAndRetryActionImpl<T> implements Action<T> {
private int wait = 0;
/**
* Constructor with a wait time expressed in milliseconds
*
* @param wait time in milliseconds
*/
public WaitAndRetryActionImpl(int wait) {
this.wait = wait;
}
@Override
public void execute(T obj, String event, Object... args) throws RetryException {
|
throw new WaitAndRetryException(this.wait);
|
statefulj/statefulj
|
statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/TransitionImpl.java
|
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/DeterministicTransitionImpl.java
// public class DeterministicTransitionImpl<T> implements Transition<T> {
//
// private StateActionPair<T> stateActionPair;
//
// public DeterministicTransitionImpl(State<T> from, State<T> to, String event) {
// stateActionPair = new StateActionPairImpl<T>(to, null);
// from.addTransition(event, this);
// }
//
// public DeterministicTransitionImpl(State<T> from, State<T> to, String event, Action<T> action) {
// stateActionPair = new StateActionPairImpl<T>(to, action);
// from.addTransition(event, this);
// }
//
// public DeterministicTransitionImpl(State<T> to, Action<T> action) {
// stateActionPair = new StateActionPairImpl<T>(to, action);
// }
//
// public DeterministicTransitionImpl(State<T> to) {
// stateActionPair = new StateActionPairImpl<T>(to, null);
// }
//
// @Override
// public StateActionPair<T> getStateActionPair(T stateful, String event, Object... args) {
// return stateActionPair;
// }
//
// public void setStateActionPair(StateActionPair<T> stateActionPair) {
// this.stateActionPair = stateActionPair;
// }
//
// @Override
// public String toString() {
// return "DeterministicTransition[state=" + this.stateActionPair.getState().getName() + ", action=" + this.stateActionPair.getAction() + "]";
// }
// }
|
import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.impl.DeterministicTransitionImpl;
|
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.fsm;
/**
* Extend {@link org.statefulj.fsm.model.impl.DeterministicTransitionImpl} to provide additional
* functionality such as "any" transition support and reloading support
*
* @author Andrew Hall
*
* @param <T> The Stateful Entity type
*/
public class TransitionImpl<T> extends DeterministicTransitionImpl<T> {
private boolean any = false;
private boolean reload = false;
public TransitionImpl(
|
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/DeterministicTransitionImpl.java
// public class DeterministicTransitionImpl<T> implements Transition<T> {
//
// private StateActionPair<T> stateActionPair;
//
// public DeterministicTransitionImpl(State<T> from, State<T> to, String event) {
// stateActionPair = new StateActionPairImpl<T>(to, null);
// from.addTransition(event, this);
// }
//
// public DeterministicTransitionImpl(State<T> from, State<T> to, String event, Action<T> action) {
// stateActionPair = new StateActionPairImpl<T>(to, action);
// from.addTransition(event, this);
// }
//
// public DeterministicTransitionImpl(State<T> to, Action<T> action) {
// stateActionPair = new StateActionPairImpl<T>(to, action);
// }
//
// public DeterministicTransitionImpl(State<T> to) {
// stateActionPair = new StateActionPairImpl<T>(to, null);
// }
//
// @Override
// public StateActionPair<T> getStateActionPair(T stateful, String event, Object... args) {
// return stateActionPair;
// }
//
// public void setStateActionPair(StateActionPair<T> stateActionPair) {
// this.stateActionPair = stateActionPair;
// }
//
// @Override
// public String toString() {
// return "DeterministicTransition[state=" + this.stateActionPair.getState().getName() + ", action=" + this.stateActionPair.getAction() + "]";
// }
// }
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/TransitionImpl.java
import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.impl.DeterministicTransitionImpl;
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.fsm;
/**
* Extend {@link org.statefulj.fsm.model.impl.DeterministicTransitionImpl} to provide additional
* functionality such as "any" transition support and reloading support
*
* @author Andrew Hall
*
* @param <T> The Stateful Entity type
*/
public class TransitionImpl<T> extends DeterministicTransitionImpl<T> {
private boolean any = false;
private boolean reload = false;
public TransitionImpl(
|
State<T> from,
|
statefulj/statefulj
|
statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/TransitionImpl.java
|
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/DeterministicTransitionImpl.java
// public class DeterministicTransitionImpl<T> implements Transition<T> {
//
// private StateActionPair<T> stateActionPair;
//
// public DeterministicTransitionImpl(State<T> from, State<T> to, String event) {
// stateActionPair = new StateActionPairImpl<T>(to, null);
// from.addTransition(event, this);
// }
//
// public DeterministicTransitionImpl(State<T> from, State<T> to, String event, Action<T> action) {
// stateActionPair = new StateActionPairImpl<T>(to, action);
// from.addTransition(event, this);
// }
//
// public DeterministicTransitionImpl(State<T> to, Action<T> action) {
// stateActionPair = new StateActionPairImpl<T>(to, action);
// }
//
// public DeterministicTransitionImpl(State<T> to) {
// stateActionPair = new StateActionPairImpl<T>(to, null);
// }
//
// @Override
// public StateActionPair<T> getStateActionPair(T stateful, String event, Object... args) {
// return stateActionPair;
// }
//
// public void setStateActionPair(StateActionPair<T> stateActionPair) {
// this.stateActionPair = stateActionPair;
// }
//
// @Override
// public String toString() {
// return "DeterministicTransition[state=" + this.stateActionPair.getState().getName() + ", action=" + this.stateActionPair.getAction() + "]";
// }
// }
|
import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.impl.DeterministicTransitionImpl;
|
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.fsm;
/**
* Extend {@link org.statefulj.fsm.model.impl.DeterministicTransitionImpl} to provide additional
* functionality such as "any" transition support and reloading support
*
* @author Andrew Hall
*
* @param <T> The Stateful Entity type
*/
public class TransitionImpl<T> extends DeterministicTransitionImpl<T> {
private boolean any = false;
private boolean reload = false;
public TransitionImpl(
State<T> from,
State<T> to,
String event,
|
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/Action.java
// public interface Action<T> {
//
// /**
// * Called to execute an action based off a State Transition.
// *
// * @param stateful The Stateful Entity
// * @param event The ocurring Event
// * @param args A set of optional arguments passed into the onEvent method of the {@link org.statefulj.fsm.FSM}
// * @throws RetryException thrown when the event must be retried due to Stale state or some other error condition
// */
// void execute(T stateful, String event, Object ... args) throws RetryException;
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/State.java
// public interface State<T> {
//
// /**
// * Name of the State. This value is persisted as the State value in the Stateful Entity.
// *
// * @return Name of the State
// */
// String getName();
//
// /**
// * Returns the Transition for an Event
// *
// * @param event The event
// * @return The Transition for this event
// *
// */
// Transition<T> getTransition(String event);
//
// /**
// * Whether this State is an End State
// *
// * @return if true, then this is an End State
// */
// boolean isEndState();
//
// /**
// * Whether this is a Blocking State. If Blocking, event will not process unless there is an explicit Transition for the
// * event. If blocked, the FSM will retry the event until the FSM transitions out of the blocked State
// *
// * @return if true, then State is a "blocking" state
// */
// public boolean isBlocking();
//
// /**
// * Set whether or not this is a Blocking State
// *
// * @param isBlocking if true, then this is a blocking State
// */
// public void setBlocking(boolean isBlocking);
//
// /**
// * Remove a Transition from the State
// *
// * @param event Remove the transition for this Event
// */
// public void removeTransition(String event);
//
// /**
// * Add a {@link org.statefulj.fsm.model.Transition}
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param transition The {@link org.statefulj.fsm.model.Transition}
// */
// public void addTransition(String event, Transition<T> transition);
//
// /**
// * Add a deterministic Transition with an Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// * @param action The resulting {@link org.statefulj.fsm.model.Action}
// */
// public void addTransition(String event, State<T> next, Action<T> action);
//
// /**
// * Add a deterministic Transition with no Action
// *
// * @param event The event to add the {@link org.statefulj.fsm.model.Transition}
// * @param next The next State
// */
// public void addTransition(String event, State<T> next);
//
// }
//
// Path: statefulj-fsm/src/main/java/org/statefulj/fsm/model/impl/DeterministicTransitionImpl.java
// public class DeterministicTransitionImpl<T> implements Transition<T> {
//
// private StateActionPair<T> stateActionPair;
//
// public DeterministicTransitionImpl(State<T> from, State<T> to, String event) {
// stateActionPair = new StateActionPairImpl<T>(to, null);
// from.addTransition(event, this);
// }
//
// public DeterministicTransitionImpl(State<T> from, State<T> to, String event, Action<T> action) {
// stateActionPair = new StateActionPairImpl<T>(to, action);
// from.addTransition(event, this);
// }
//
// public DeterministicTransitionImpl(State<T> to, Action<T> action) {
// stateActionPair = new StateActionPairImpl<T>(to, action);
// }
//
// public DeterministicTransitionImpl(State<T> to) {
// stateActionPair = new StateActionPairImpl<T>(to, null);
// }
//
// @Override
// public StateActionPair<T> getStateActionPair(T stateful, String event, Object... args) {
// return stateActionPair;
// }
//
// public void setStateActionPair(StateActionPair<T> stateActionPair) {
// this.stateActionPair = stateActionPair;
// }
//
// @Override
// public String toString() {
// return "DeterministicTransition[state=" + this.stateActionPair.getState().getName() + ", action=" + this.stateActionPair.getAction() + "]";
// }
// }
// Path: statefulj-framework/statefulj-framework-core/src/main/java/org/statefulj/framework/core/fsm/TransitionImpl.java
import org.statefulj.fsm.model.Action;
import org.statefulj.fsm.model.State;
import org.statefulj.fsm.model.impl.DeterministicTransitionImpl;
/***
*
* Copyright 2014 Andrew Hall
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.statefulj.framework.core.fsm;
/**
* Extend {@link org.statefulj.fsm.model.impl.DeterministicTransitionImpl} to provide additional
* functionality such as "any" transition support and reloading support
*
* @author Andrew Hall
*
* @param <T> The Stateful Entity type
*/
public class TransitionImpl<T> extends DeterministicTransitionImpl<T> {
private boolean any = false;
private boolean reload = false;
public TransitionImpl(
State<T> from,
State<T> to,
String event,
|
Action<T> action,
|
RoRoche/AndroidModularReloaded
|
app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentMainActivity.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/MainActivity.java
// public class MainActivity
// extends AppCompatActivity
// implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Fields
// private SharedViewModel mSharedViewModel;
// private EasyFlow<FlowContext> mFlow;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// setContentView(R.layout.activity_main);
// mSharedViewModel = ViewModelProviders.of(this).get(SharedViewModel.class);
//
// mFlow =
// from(FragmentFirst.States.WAITING_LOGIN).transit(
// on(FragmentFirst.Events.loginProvided).to(FragmentSecond.States.SHOWING_WELCOME).transit(
// on(Events.backPressed).to(FragmentFirst.States.WAITING_LOGIN)
// )
// );
//
// mFlow.executor(new UiThreadExecutor());
//
// mFlow.whenEnter(FragmentFirst.States.WAITING_LOGIN, (@NonNull final FlowContext pContext) -> {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.findFragmentById(R.id.ActivityMain_ViewGroup_Container) == null) {
// lFragmentManager.beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentFirst.newInstance())
// .commit();
// }
// });
//
// mFlow.whenEnter(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> {
// final String lLogin = new FragmentFirstOutput(pContext.args()).login;
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentSecond.newInstance(lLogin))
// .addToBackStack(null)
// .commit();
// });
//
// mFlow.whenLeave(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> pContext.args().clear());
//
// mSharedViewModel.getFlowContextLiveData()
// .observe(
// this,
// (@NonNull final SharedViewModel.LiveDataFlowContext pLiveDataFlowContext) ->
// mFlow.start(pLiveDataFlowContext.forceEnterInitialState, pLiveDataFlowContext.flowContext)
// );
// }
// //endregion
//
// //region Overridden methods
// @Override
// public void onBackPressed() {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.getBackStackEntryCount() > 0) {
// mSharedViewModel.safeTrigger(Events.backPressed);
// lFragmentManager.popBackStack();
// } else {
// super.onBackPressed();
// }
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
//
// //region FSM
// private enum Events implements EventEnum {
// backPressed
// }
// //endregion
// }
//
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/di/ModuleFragmentSecond.java
// @Module(subcomponents = {
// ComponentFragmentSecond.class
// })
// public abstract class ModuleFragmentSecond {
// @Binds
// @IntoMap
// @FragmentKey(FragmentSecond.class)
// abstract AndroidInjector.Factory<? extends Fragment> fragmentSecondInjectorFactory(final ComponentFragmentSecond.Builder pBuilder);
// }
|
import dagger.Subcomponent;
import dagger.android.AndroidInjector;
import fr.guddy.android_modular_reloaded.MainActivity;
import fr.guddy.android_modular_reloaded.second.di.ModuleFragmentSecond;
|
package fr.guddy.android_modular_reloaded.di;
@Subcomponent(modules = {
ModuleMainActivity.class,
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/MainActivity.java
// public class MainActivity
// extends AppCompatActivity
// implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Fields
// private SharedViewModel mSharedViewModel;
// private EasyFlow<FlowContext> mFlow;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// setContentView(R.layout.activity_main);
// mSharedViewModel = ViewModelProviders.of(this).get(SharedViewModel.class);
//
// mFlow =
// from(FragmentFirst.States.WAITING_LOGIN).transit(
// on(FragmentFirst.Events.loginProvided).to(FragmentSecond.States.SHOWING_WELCOME).transit(
// on(Events.backPressed).to(FragmentFirst.States.WAITING_LOGIN)
// )
// );
//
// mFlow.executor(new UiThreadExecutor());
//
// mFlow.whenEnter(FragmentFirst.States.WAITING_LOGIN, (@NonNull final FlowContext pContext) -> {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.findFragmentById(R.id.ActivityMain_ViewGroup_Container) == null) {
// lFragmentManager.beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentFirst.newInstance())
// .commit();
// }
// });
//
// mFlow.whenEnter(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> {
// final String lLogin = new FragmentFirstOutput(pContext.args()).login;
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentSecond.newInstance(lLogin))
// .addToBackStack(null)
// .commit();
// });
//
// mFlow.whenLeave(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> pContext.args().clear());
//
// mSharedViewModel.getFlowContextLiveData()
// .observe(
// this,
// (@NonNull final SharedViewModel.LiveDataFlowContext pLiveDataFlowContext) ->
// mFlow.start(pLiveDataFlowContext.forceEnterInitialState, pLiveDataFlowContext.flowContext)
// );
// }
// //endregion
//
// //region Overridden methods
// @Override
// public void onBackPressed() {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.getBackStackEntryCount() > 0) {
// mSharedViewModel.safeTrigger(Events.backPressed);
// lFragmentManager.popBackStack();
// } else {
// super.onBackPressed();
// }
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
//
// //region FSM
// private enum Events implements EventEnum {
// backPressed
// }
// //endregion
// }
//
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/di/ModuleFragmentSecond.java
// @Module(subcomponents = {
// ComponentFragmentSecond.class
// })
// public abstract class ModuleFragmentSecond {
// @Binds
// @IntoMap
// @FragmentKey(FragmentSecond.class)
// abstract AndroidInjector.Factory<? extends Fragment> fragmentSecondInjectorFactory(final ComponentFragmentSecond.Builder pBuilder);
// }
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentMainActivity.java
import dagger.Subcomponent;
import dagger.android.AndroidInjector;
import fr.guddy.android_modular_reloaded.MainActivity;
import fr.guddy.android_modular_reloaded.second.di.ModuleFragmentSecond;
package fr.guddy.android_modular_reloaded.di;
@Subcomponent(modules = {
ModuleMainActivity.class,
|
ModuleFragmentSecond.class
|
RoRoche/AndroidModularReloaded
|
app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentMainActivity.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/MainActivity.java
// public class MainActivity
// extends AppCompatActivity
// implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Fields
// private SharedViewModel mSharedViewModel;
// private EasyFlow<FlowContext> mFlow;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// setContentView(R.layout.activity_main);
// mSharedViewModel = ViewModelProviders.of(this).get(SharedViewModel.class);
//
// mFlow =
// from(FragmentFirst.States.WAITING_LOGIN).transit(
// on(FragmentFirst.Events.loginProvided).to(FragmentSecond.States.SHOWING_WELCOME).transit(
// on(Events.backPressed).to(FragmentFirst.States.WAITING_LOGIN)
// )
// );
//
// mFlow.executor(new UiThreadExecutor());
//
// mFlow.whenEnter(FragmentFirst.States.WAITING_LOGIN, (@NonNull final FlowContext pContext) -> {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.findFragmentById(R.id.ActivityMain_ViewGroup_Container) == null) {
// lFragmentManager.beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentFirst.newInstance())
// .commit();
// }
// });
//
// mFlow.whenEnter(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> {
// final String lLogin = new FragmentFirstOutput(pContext.args()).login;
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentSecond.newInstance(lLogin))
// .addToBackStack(null)
// .commit();
// });
//
// mFlow.whenLeave(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> pContext.args().clear());
//
// mSharedViewModel.getFlowContextLiveData()
// .observe(
// this,
// (@NonNull final SharedViewModel.LiveDataFlowContext pLiveDataFlowContext) ->
// mFlow.start(pLiveDataFlowContext.forceEnterInitialState, pLiveDataFlowContext.flowContext)
// );
// }
// //endregion
//
// //region Overridden methods
// @Override
// public void onBackPressed() {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.getBackStackEntryCount() > 0) {
// mSharedViewModel.safeTrigger(Events.backPressed);
// lFragmentManager.popBackStack();
// } else {
// super.onBackPressed();
// }
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
//
// //region FSM
// private enum Events implements EventEnum {
// backPressed
// }
// //endregion
// }
//
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/di/ModuleFragmentSecond.java
// @Module(subcomponents = {
// ComponentFragmentSecond.class
// })
// public abstract class ModuleFragmentSecond {
// @Binds
// @IntoMap
// @FragmentKey(FragmentSecond.class)
// abstract AndroidInjector.Factory<? extends Fragment> fragmentSecondInjectorFactory(final ComponentFragmentSecond.Builder pBuilder);
// }
|
import dagger.Subcomponent;
import dagger.android.AndroidInjector;
import fr.guddy.android_modular_reloaded.MainActivity;
import fr.guddy.android_modular_reloaded.second.di.ModuleFragmentSecond;
|
package fr.guddy.android_modular_reloaded.di;
@Subcomponent(modules = {
ModuleMainActivity.class,
ModuleFragmentSecond.class
})
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/MainActivity.java
// public class MainActivity
// extends AppCompatActivity
// implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Fields
// private SharedViewModel mSharedViewModel;
// private EasyFlow<FlowContext> mFlow;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// setContentView(R.layout.activity_main);
// mSharedViewModel = ViewModelProviders.of(this).get(SharedViewModel.class);
//
// mFlow =
// from(FragmentFirst.States.WAITING_LOGIN).transit(
// on(FragmentFirst.Events.loginProvided).to(FragmentSecond.States.SHOWING_WELCOME).transit(
// on(Events.backPressed).to(FragmentFirst.States.WAITING_LOGIN)
// )
// );
//
// mFlow.executor(new UiThreadExecutor());
//
// mFlow.whenEnter(FragmentFirst.States.WAITING_LOGIN, (@NonNull final FlowContext pContext) -> {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.findFragmentById(R.id.ActivityMain_ViewGroup_Container) == null) {
// lFragmentManager.beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentFirst.newInstance())
// .commit();
// }
// });
//
// mFlow.whenEnter(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> {
// final String lLogin = new FragmentFirstOutput(pContext.args()).login;
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentSecond.newInstance(lLogin))
// .addToBackStack(null)
// .commit();
// });
//
// mFlow.whenLeave(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> pContext.args().clear());
//
// mSharedViewModel.getFlowContextLiveData()
// .observe(
// this,
// (@NonNull final SharedViewModel.LiveDataFlowContext pLiveDataFlowContext) ->
// mFlow.start(pLiveDataFlowContext.forceEnterInitialState, pLiveDataFlowContext.flowContext)
// );
// }
// //endregion
//
// //region Overridden methods
// @Override
// public void onBackPressed() {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.getBackStackEntryCount() > 0) {
// mSharedViewModel.safeTrigger(Events.backPressed);
// lFragmentManager.popBackStack();
// } else {
// super.onBackPressed();
// }
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
//
// //region FSM
// private enum Events implements EventEnum {
// backPressed
// }
// //endregion
// }
//
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/di/ModuleFragmentSecond.java
// @Module(subcomponents = {
// ComponentFragmentSecond.class
// })
// public abstract class ModuleFragmentSecond {
// @Binds
// @IntoMap
// @FragmentKey(FragmentSecond.class)
// abstract AndroidInjector.Factory<? extends Fragment> fragmentSecondInjectorFactory(final ComponentFragmentSecond.Builder pBuilder);
// }
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentMainActivity.java
import dagger.Subcomponent;
import dagger.android.AndroidInjector;
import fr.guddy.android_modular_reloaded.MainActivity;
import fr.guddy.android_modular_reloaded.second.di.ModuleFragmentSecond;
package fr.guddy.android_modular_reloaded.di;
@Subcomponent(modules = {
ModuleMainActivity.class,
ModuleFragmentSecond.class
})
|
public interface ComponentMainActivity extends AndroidInjector<MainActivity> {
|
RoRoche/AndroidModularReloaded
|
app/src/main/java/fr/guddy/android_modular_reloaded/di/ActivityBindingModule.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/MainActivity.java
// public class MainActivity
// extends AppCompatActivity
// implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Fields
// private SharedViewModel mSharedViewModel;
// private EasyFlow<FlowContext> mFlow;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// setContentView(R.layout.activity_main);
// mSharedViewModel = ViewModelProviders.of(this).get(SharedViewModel.class);
//
// mFlow =
// from(FragmentFirst.States.WAITING_LOGIN).transit(
// on(FragmentFirst.Events.loginProvided).to(FragmentSecond.States.SHOWING_WELCOME).transit(
// on(Events.backPressed).to(FragmentFirst.States.WAITING_LOGIN)
// )
// );
//
// mFlow.executor(new UiThreadExecutor());
//
// mFlow.whenEnter(FragmentFirst.States.WAITING_LOGIN, (@NonNull final FlowContext pContext) -> {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.findFragmentById(R.id.ActivityMain_ViewGroup_Container) == null) {
// lFragmentManager.beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentFirst.newInstance())
// .commit();
// }
// });
//
// mFlow.whenEnter(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> {
// final String lLogin = new FragmentFirstOutput(pContext.args()).login;
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentSecond.newInstance(lLogin))
// .addToBackStack(null)
// .commit();
// });
//
// mFlow.whenLeave(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> pContext.args().clear());
//
// mSharedViewModel.getFlowContextLiveData()
// .observe(
// this,
// (@NonNull final SharedViewModel.LiveDataFlowContext pLiveDataFlowContext) ->
// mFlow.start(pLiveDataFlowContext.forceEnterInitialState, pLiveDataFlowContext.flowContext)
// );
// }
// //endregion
//
// //region Overridden methods
// @Override
// public void onBackPressed() {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.getBackStackEntryCount() > 0) {
// mSharedViewModel.safeTrigger(Events.backPressed);
// lFragmentManager.popBackStack();
// } else {
// super.onBackPressed();
// }
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
//
// //region FSM
// private enum Events implements EventEnum {
// backPressed
// }
// //endregion
// }
|
import android.app.Activity;
import dagger.Binds;
import dagger.Module;
import dagger.android.ActivityKey;
import dagger.android.AndroidInjector;
import dagger.multibindings.IntoMap;
import fr.guddy.android_modular_reloaded.MainActivity;
|
package fr.guddy.android_modular_reloaded.di;
@Module(subcomponents = {
ComponentMainActivity.class
})
public abstract class ActivityBindingModule {
@Binds
@IntoMap
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/MainActivity.java
// public class MainActivity
// extends AppCompatActivity
// implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Fields
// private SharedViewModel mSharedViewModel;
// private EasyFlow<FlowContext> mFlow;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// setContentView(R.layout.activity_main);
// mSharedViewModel = ViewModelProviders.of(this).get(SharedViewModel.class);
//
// mFlow =
// from(FragmentFirst.States.WAITING_LOGIN).transit(
// on(FragmentFirst.Events.loginProvided).to(FragmentSecond.States.SHOWING_WELCOME).transit(
// on(Events.backPressed).to(FragmentFirst.States.WAITING_LOGIN)
// )
// );
//
// mFlow.executor(new UiThreadExecutor());
//
// mFlow.whenEnter(FragmentFirst.States.WAITING_LOGIN, (@NonNull final FlowContext pContext) -> {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.findFragmentById(R.id.ActivityMain_ViewGroup_Container) == null) {
// lFragmentManager.beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentFirst.newInstance())
// .commit();
// }
// });
//
// mFlow.whenEnter(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> {
// final String lLogin = new FragmentFirstOutput(pContext.args()).login;
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.ActivityMain_ViewGroup_Container, FragmentSecond.newInstance(lLogin))
// .addToBackStack(null)
// .commit();
// });
//
// mFlow.whenLeave(FragmentSecond.States.SHOWING_WELCOME, (@NonNull final FlowContext pContext) -> pContext.args().clear());
//
// mSharedViewModel.getFlowContextLiveData()
// .observe(
// this,
// (@NonNull final SharedViewModel.LiveDataFlowContext pLiveDataFlowContext) ->
// mFlow.start(pLiveDataFlowContext.forceEnterInitialState, pLiveDataFlowContext.flowContext)
// );
// }
// //endregion
//
// //region Overridden methods
// @Override
// public void onBackPressed() {
// final FragmentManager lFragmentManager = getSupportFragmentManager();
// if (lFragmentManager.getBackStackEntryCount() > 0) {
// mSharedViewModel.safeTrigger(Events.backPressed);
// lFragmentManager.popBackStack();
// } else {
// super.onBackPressed();
// }
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
//
// //region FSM
// private enum Events implements EventEnum {
// backPressed
// }
// //endregion
// }
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ActivityBindingModule.java
import android.app.Activity;
import dagger.Binds;
import dagger.Module;
import dagger.android.ActivityKey;
import dagger.android.AndroidInjector;
import dagger.multibindings.IntoMap;
import fr.guddy.android_modular_reloaded.MainActivity;
package fr.guddy.android_modular_reloaded.di;
@Module(subcomponents = {
ComponentMainActivity.class
})
public abstract class ActivityBindingModule {
@Binds
@IntoMap
|
@ActivityKey(MainActivity.class)
|
RoRoche/AndroidModularReloaded
|
second/src/main/java/fr/guddy/android_modular_reloaded/second/di/ModuleFragmentSecond.java
|
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/FragmentSecond.java
// public class FragmentSecond extends Fragment {
//
// //region Constants for args
// private static final String ARG_LOGIN = "login";
// //endregion
//
// //region Args
// private String mLogin;
// //endregion
//
// //region Injected fields
// @Inject
// public IDateFormatter dateFormatter;
// //endregion
//
// //region Factory
// public static FragmentSecond newInstance(@NonNull final String pLogin) {
// final FragmentSecond lFragment = new FragmentSecond();
// final Bundle lArgs = new Bundle();
// lArgs.putString(ARG_LOGIN, pLogin);
// lFragment.setArguments(lArgs);
// return lFragment;
// }
// //endregion
//
// //region Lifecycle
// @Override
// public void onAttach(final Context pContext) {
// AndroidSupportInjection.inject(this);
// super.onAttach(pContext);
// Preconditions.checkNotNull(dateFormatter, "Field dateFormatter is null, did you miss to inject it with your dependency injection mechanism?");
// }
//
// @Override
// public void onCreate(@Nullable final Bundle pSavedInstanceState) {
// super.onCreate(pSavedInstanceState);
// if (getArguments() != null) {
// mLogin = getArguments().getString(ARG_LOGIN);
// }
// }
//
// @Override
// public View onCreateView(final LayoutInflater pInflater,
// final ViewGroup pContainer,
// final Bundle pSavedInstanceState) {
// final View lRootView = pInflater.inflate(R.layout.fragment_second, pContainer, false);
// final TextView lTextViewWelcome = lRootView.findViewById(R.id.FragmentSecond_TextView_Welcome);
// lTextViewWelcome.setText(getString(R.string.hello_fragment_second, mLogin, dateFormatter.format(new Date())));
// return lRootView;
// }
// //endregion
//
// //region FSM
// public enum States implements StateEnum {
// SHOWING_WELCOME
// }
// //endregion
// }
|
import android.support.v4.app.Fragment;
import dagger.Binds;
import dagger.Module;
import dagger.android.AndroidInjector;
import dagger.android.support.FragmentKey;
import dagger.multibindings.IntoMap;
import fr.guddy.android_modular_reloaded.second.FragmentSecond;
|
package fr.guddy.android_modular_reloaded.second.di;
@Module(subcomponents = {
ComponentFragmentSecond.class
})
public abstract class ModuleFragmentSecond {
@Binds
@IntoMap
|
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/FragmentSecond.java
// public class FragmentSecond extends Fragment {
//
// //region Constants for args
// private static final String ARG_LOGIN = "login";
// //endregion
//
// //region Args
// private String mLogin;
// //endregion
//
// //region Injected fields
// @Inject
// public IDateFormatter dateFormatter;
// //endregion
//
// //region Factory
// public static FragmentSecond newInstance(@NonNull final String pLogin) {
// final FragmentSecond lFragment = new FragmentSecond();
// final Bundle lArgs = new Bundle();
// lArgs.putString(ARG_LOGIN, pLogin);
// lFragment.setArguments(lArgs);
// return lFragment;
// }
// //endregion
//
// //region Lifecycle
// @Override
// public void onAttach(final Context pContext) {
// AndroidSupportInjection.inject(this);
// super.onAttach(pContext);
// Preconditions.checkNotNull(dateFormatter, "Field dateFormatter is null, did you miss to inject it with your dependency injection mechanism?");
// }
//
// @Override
// public void onCreate(@Nullable final Bundle pSavedInstanceState) {
// super.onCreate(pSavedInstanceState);
// if (getArguments() != null) {
// mLogin = getArguments().getString(ARG_LOGIN);
// }
// }
//
// @Override
// public View onCreateView(final LayoutInflater pInflater,
// final ViewGroup pContainer,
// final Bundle pSavedInstanceState) {
// final View lRootView = pInflater.inflate(R.layout.fragment_second, pContainer, false);
// final TextView lTextViewWelcome = lRootView.findViewById(R.id.FragmentSecond_TextView_Welcome);
// lTextViewWelcome.setText(getString(R.string.hello_fragment_second, mLogin, dateFormatter.format(new Date())));
// return lRootView;
// }
// //endregion
//
// //region FSM
// public enum States implements StateEnum {
// SHOWING_WELCOME
// }
// //endregion
// }
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/di/ModuleFragmentSecond.java
import android.support.v4.app.Fragment;
import dagger.Binds;
import dagger.Module;
import dagger.android.AndroidInjector;
import dagger.android.support.FragmentKey;
import dagger.multibindings.IntoMap;
import fr.guddy.android_modular_reloaded.second.FragmentSecond;
package fr.guddy.android_modular_reloaded.second.di;
@Module(subcomponents = {
ComponentFragmentSecond.class
})
public abstract class ModuleFragmentSecond {
@Binds
@IntoMap
|
@FragmentKey(FragmentSecond.class)
|
RoRoche/AndroidModularReloaded
|
first/src/main/java/fr/guddy/android_modular_reloaded/first/FragmentFirst.java
|
// Path: common/src/main/java/fr/guddy/android_modular_reloaded/common/SharedViewModel.java
// public class SharedViewModel extends ViewModel {
//
// //region Fields
// private final MutableLiveData<LiveDataFlowContext> mFlowContextLiveData;
// private FlowContext mFlowContext;
// //endregion
//
// //region Constructor
// public SharedViewModel() {
// mFlowContextLiveData = new MutableLiveData<>();
// mFlowContext = new FlowContext();
// mFlowContextLiveData.setValue(new LiveDataFlowContext(false, mFlowContext));
// }
// //endregion
//
// //region Visible API
// public LiveData<LiveDataFlowContext> getFlowContextLiveData() {
// return mFlowContextLiveData;
// }
//
// public Bundle args() {
// return mFlowContext.args();
// }
//
// public void safeTrigger(final EventEnum pEvent) {
// final LiveDataFlowContext lValue = mFlowContextLiveData.getValue();
// if(lValue != null) {
// lValue.flowContext.safeTrigger(pEvent);
// }
// }
// //endregion
//
// //region Visible for testing API
// @VisibleForTesting
// public void setFlowContext(final FlowContext pFlowContext) {
// mFlowContext = pFlowContext;
// mFlowContextLiveData.setValue(new LiveDataFlowContext(true, pFlowContext));
// }
// //endregion
//
// public static final class LiveDataFlowContext {
// public final boolean forceEnterInitialState;
// public final FlowContext flowContext;
//
// private LiveDataFlowContext(final boolean pForceEnterInitialState, @NonNull final FlowContext pFlowContext) {
// forceEnterInitialState = pForceEnterInitialState;
// flowContext = pFlowContext;
// }
// }
// }
|
import android.arch.lifecycle.ViewModelProviders;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputEditText;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import au.com.ds.ef.EventEnum;
import au.com.ds.ef.StateEnum;
import fr.guddy.android_modular_reloaded.common.SharedViewModel;
|
package fr.guddy.android_modular_reloaded.first;
public class FragmentFirst extends Fragment {
//region Constants
private static final String ARG_KEY_PRE_FILLED_LOGIN = "PRE_FILLED_LOGIN";
//endregion
//region Bound views
private TextInputEditText mEditTextLogin;
//endregion
//region Fields
|
// Path: common/src/main/java/fr/guddy/android_modular_reloaded/common/SharedViewModel.java
// public class SharedViewModel extends ViewModel {
//
// //region Fields
// private final MutableLiveData<LiveDataFlowContext> mFlowContextLiveData;
// private FlowContext mFlowContext;
// //endregion
//
// //region Constructor
// public SharedViewModel() {
// mFlowContextLiveData = new MutableLiveData<>();
// mFlowContext = new FlowContext();
// mFlowContextLiveData.setValue(new LiveDataFlowContext(false, mFlowContext));
// }
// //endregion
//
// //region Visible API
// public LiveData<LiveDataFlowContext> getFlowContextLiveData() {
// return mFlowContextLiveData;
// }
//
// public Bundle args() {
// return mFlowContext.args();
// }
//
// public void safeTrigger(final EventEnum pEvent) {
// final LiveDataFlowContext lValue = mFlowContextLiveData.getValue();
// if(lValue != null) {
// lValue.flowContext.safeTrigger(pEvent);
// }
// }
// //endregion
//
// //region Visible for testing API
// @VisibleForTesting
// public void setFlowContext(final FlowContext pFlowContext) {
// mFlowContext = pFlowContext;
// mFlowContextLiveData.setValue(new LiveDataFlowContext(true, pFlowContext));
// }
// //endregion
//
// public static final class LiveDataFlowContext {
// public final boolean forceEnterInitialState;
// public final FlowContext flowContext;
//
// private LiveDataFlowContext(final boolean pForceEnterInitialState, @NonNull final FlowContext pFlowContext) {
// forceEnterInitialState = pForceEnterInitialState;
// flowContext = pFlowContext;
// }
// }
// }
// Path: first/src/main/java/fr/guddy/android_modular_reloaded/first/FragmentFirst.java
import android.arch.lifecycle.ViewModelProviders;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputEditText;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import au.com.ds.ef.EventEnum;
import au.com.ds.ef.StateEnum;
import fr.guddy.android_modular_reloaded.common.SharedViewModel;
package fr.guddy.android_modular_reloaded.first;
public class FragmentFirst extends Fragment {
//region Constants
private static final String ARG_KEY_PRE_FILLED_LOGIN = "PRE_FILLED_LOGIN";
//endregion
//region Bound views
private TextInputEditText mEditTextLogin;
//endregion
//region Fields
|
private SharedViewModel mSharedViewModel;
|
RoRoche/AndroidModularReloaded
|
second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ModuleDebugActivity.java
|
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/IDateFormatter.java
// public interface IDateFormatter {
// String format(@NonNull final Date poDate);
// }
|
import dagger.Module;
import dagger.Provides;
import fr.guddy.android_modular_reloaded.second.IDateFormatter;
|
package fr.guddy.android_modular_reloaded.second.di;
@Module
public class ModuleDebugActivity {
//region Provides
@Provides
|
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/IDateFormatter.java
// public interface IDateFormatter {
// String format(@NonNull final Date poDate);
// }
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ModuleDebugActivity.java
import dagger.Module;
import dagger.Provides;
import fr.guddy.android_modular_reloaded.second.IDateFormatter;
package fr.guddy.android_modular_reloaded.second.di;
@Module
public class ModuleDebugActivity {
//region Provides
@Provides
|
public IDateFormatter providesDateFormatter() {
|
RoRoche/AndroidModularReloaded
|
second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ComponentDebugApp.java
|
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/DebugApp.java
// public class DebugApp extends AbstractDebugApp {
//
// //region AbstractDebugApp overridden method
// @Override
// protected void buildComponentAndInjectThis() {
// DaggerComponentDebugApp.builder()
// .application(this)
// .build()
// .inject(this);
// }
// //endregion
// }
|
import javax.inject.Singleton;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.support.AndroidSupportInjectionModule;
import fr.guddy.android_modular_reloaded.second.DebugApp;
|
package fr.guddy.android_modular_reloaded.second.di;
@Singleton
@Component(modules = {
AndroidSupportInjectionModule.class,
ModuleDebugActivity.class,
ActivityBindingModule.class,
})
public interface ComponentDebugApp {
@Component.Builder
interface Builder {
@BindsInstance
|
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/DebugApp.java
// public class DebugApp extends AbstractDebugApp {
//
// //region AbstractDebugApp overridden method
// @Override
// protected void buildComponentAndInjectThis() {
// DaggerComponentDebugApp.builder()
// .application(this)
// .build()
// .inject(this);
// }
// //endregion
// }
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ComponentDebugApp.java
import javax.inject.Singleton;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.support.AndroidSupportInjectionModule;
import fr.guddy.android_modular_reloaded.second.DebugApp;
package fr.guddy.android_modular_reloaded.second.di;
@Singleton
@Component(modules = {
AndroidSupportInjectionModule.class,
ModuleDebugActivity.class,
ActivityBindingModule.class,
})
public interface ComponentDebugApp {
@Component.Builder
interface Builder {
@BindsInstance
|
Builder application(final DebugApp pDebugApp);
|
RoRoche/AndroidModularReloaded
|
app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleMainActivity.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/second/DateFormatter.java
// public final class DateFormatter implements IDateFormatter {
//
// //region Constants
// private static final String DATE_FORMAT = "dd/MM/yyyy";
// private static final SimpleDateFormat sSimpleDateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
// //endregion
//
// //region IDateFormatter
// @Override
// public String format(@NonNull final Date poDate) {
// return sSimpleDateFormat.format(poDate);
// }
// //endregion
// }
//
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/IDateFormatter.java
// public interface IDateFormatter {
// String format(@NonNull final Date poDate);
// }
|
import dagger.Module;
import dagger.Provides;
import fr.guddy.android_modular_reloaded.di.second.DateFormatter;
import fr.guddy.android_modular_reloaded.second.IDateFormatter;
|
package fr.guddy.android_modular_reloaded.di;
@Module
public class ModuleMainActivity {
//region Provides
@Provides
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/second/DateFormatter.java
// public final class DateFormatter implements IDateFormatter {
//
// //region Constants
// private static final String DATE_FORMAT = "dd/MM/yyyy";
// private static final SimpleDateFormat sSimpleDateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
// //endregion
//
// //region IDateFormatter
// @Override
// public String format(@NonNull final Date poDate) {
// return sSimpleDateFormat.format(poDate);
// }
// //endregion
// }
//
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/IDateFormatter.java
// public interface IDateFormatter {
// String format(@NonNull final Date poDate);
// }
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleMainActivity.java
import dagger.Module;
import dagger.Provides;
import fr.guddy.android_modular_reloaded.di.second.DateFormatter;
import fr.guddy.android_modular_reloaded.second.IDateFormatter;
package fr.guddy.android_modular_reloaded.di;
@Module
public class ModuleMainActivity {
//region Provides
@Provides
|
public IDateFormatter providesDateFormatter() {
|
RoRoche/AndroidModularReloaded
|
app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleMainActivity.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/second/DateFormatter.java
// public final class DateFormatter implements IDateFormatter {
//
// //region Constants
// private static final String DATE_FORMAT = "dd/MM/yyyy";
// private static final SimpleDateFormat sSimpleDateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
// //endregion
//
// //region IDateFormatter
// @Override
// public String format(@NonNull final Date poDate) {
// return sSimpleDateFormat.format(poDate);
// }
// //endregion
// }
//
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/IDateFormatter.java
// public interface IDateFormatter {
// String format(@NonNull final Date poDate);
// }
|
import dagger.Module;
import dagger.Provides;
import fr.guddy.android_modular_reloaded.di.second.DateFormatter;
import fr.guddy.android_modular_reloaded.second.IDateFormatter;
|
package fr.guddy.android_modular_reloaded.di;
@Module
public class ModuleMainActivity {
//region Provides
@Provides
public IDateFormatter providesDateFormatter() {
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/second/DateFormatter.java
// public final class DateFormatter implements IDateFormatter {
//
// //region Constants
// private static final String DATE_FORMAT = "dd/MM/yyyy";
// private static final SimpleDateFormat sSimpleDateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
// //endregion
//
// //region IDateFormatter
// @Override
// public String format(@NonNull final Date poDate) {
// return sSimpleDateFormat.format(poDate);
// }
// //endregion
// }
//
// Path: second/src/main/java/fr/guddy/android_modular_reloaded/second/IDateFormatter.java
// public interface IDateFormatter {
// String format(@NonNull final Date poDate);
// }
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleMainActivity.java
import dagger.Module;
import dagger.Provides;
import fr.guddy.android_modular_reloaded.di.second.DateFormatter;
import fr.guddy.android_modular_reloaded.second.IDateFormatter;
package fr.guddy.android_modular_reloaded.di;
@Module
public class ModuleMainActivity {
//region Provides
@Provides
public IDateFormatter providesDateFormatter() {
|
return new DateFormatter();
|
RoRoche/AndroidModularReloaded
|
app/src/main/java/fr/guddy/android_modular_reloaded/App.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleApp.class,
// ModuleMainActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final App pApp);
//
// Builder moduleApp(final ModuleApp pModuleApp);
//
// Builder moduleMainActivity(final ModuleMainActivity pModuleMainActivity);
//
// ComponentApp build();
// }
//
// void inject(final App pApp);
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
// @Module
// public class ModuleApp {
// //region Field
// private final App mApp;
// //endregion
//
// //region Constructor
// public ModuleApp(@NonNull final App pApp) {
// mApp = pApp;
// }
// //endregion
//
// //region Provides
// @Singleton
// @Provides
// public App providesApp() {
// return mApp;
// }
// //endregion
// }
|
import android.app.Activity;
import android.app.Application;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import javax.inject.Inject;
import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
import fr.guddy.android_modular_reloaded.di.ComponentApp;
import fr.guddy.android_modular_reloaded.di.DaggerComponentApp;
import fr.guddy.android_modular_reloaded.di.ModuleApp;
|
package fr.guddy.android_modular_reloaded;
public class App extends Application implements HasActivityInjector {
//region Injected fields
@Inject
public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
//endregion
//region Fields
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleApp.class,
// ModuleMainActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final App pApp);
//
// Builder moduleApp(final ModuleApp pModuleApp);
//
// Builder moduleMainActivity(final ModuleMainActivity pModuleMainActivity);
//
// ComponentApp build();
// }
//
// void inject(final App pApp);
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
// @Module
// public class ModuleApp {
// //region Field
// private final App mApp;
// //endregion
//
// //region Constructor
// public ModuleApp(@NonNull final App pApp) {
// mApp = pApp;
// }
// //endregion
//
// //region Provides
// @Singleton
// @Provides
// public App providesApp() {
// return mApp;
// }
// //endregion
// }
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
import android.app.Activity;
import android.app.Application;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import javax.inject.Inject;
import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
import fr.guddy.android_modular_reloaded.di.ComponentApp;
import fr.guddy.android_modular_reloaded.di.DaggerComponentApp;
import fr.guddy.android_modular_reloaded.di.ModuleApp;
package fr.guddy.android_modular_reloaded;
public class App extends Application implements HasActivityInjector {
//region Injected fields
@Inject
public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
//endregion
//region Fields
|
private ComponentApp mComponentApp;
|
RoRoche/AndroidModularReloaded
|
app/src/main/java/fr/guddy/android_modular_reloaded/App.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleApp.class,
// ModuleMainActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final App pApp);
//
// Builder moduleApp(final ModuleApp pModuleApp);
//
// Builder moduleMainActivity(final ModuleMainActivity pModuleMainActivity);
//
// ComponentApp build();
// }
//
// void inject(final App pApp);
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
// @Module
// public class ModuleApp {
// //region Field
// private final App mApp;
// //endregion
//
// //region Constructor
// public ModuleApp(@NonNull final App pApp) {
// mApp = pApp;
// }
// //endregion
//
// //region Provides
// @Singleton
// @Provides
// public App providesApp() {
// return mApp;
// }
// //endregion
// }
|
import android.app.Activity;
import android.app.Application;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import javax.inject.Inject;
import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
import fr.guddy.android_modular_reloaded.di.ComponentApp;
import fr.guddy.android_modular_reloaded.di.DaggerComponentApp;
import fr.guddy.android_modular_reloaded.di.ModuleApp;
|
package fr.guddy.android_modular_reloaded;
public class App extends Application implements HasActivityInjector {
//region Injected fields
@Inject
public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
//endregion
//region Fields
private ComponentApp mComponentApp;
//endregion
//region Lifecycle
@Override
public void onCreate() {
super.onCreate();
buildComponent();
mComponentApp.inject(this);
}
//endregion
//region DI setup
private void buildComponent() {
mComponentApp = DaggerComponentApp.builder()
.application(this)
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleApp.class,
// ModuleMainActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final App pApp);
//
// Builder moduleApp(final ModuleApp pModuleApp);
//
// Builder moduleMainActivity(final ModuleMainActivity pModuleMainActivity);
//
// ComponentApp build();
// }
//
// void inject(final App pApp);
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
// @Module
// public class ModuleApp {
// //region Field
// private final App mApp;
// //endregion
//
// //region Constructor
// public ModuleApp(@NonNull final App pApp) {
// mApp = pApp;
// }
// //endregion
//
// //region Provides
// @Singleton
// @Provides
// public App providesApp() {
// return mApp;
// }
// //endregion
// }
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
import android.app.Activity;
import android.app.Application;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import javax.inject.Inject;
import dagger.android.AndroidInjector;
import dagger.android.DispatchingAndroidInjector;
import dagger.android.HasActivityInjector;
import fr.guddy.android_modular_reloaded.di.ComponentApp;
import fr.guddy.android_modular_reloaded.di.DaggerComponentApp;
import fr.guddy.android_modular_reloaded.di.ModuleApp;
package fr.guddy.android_modular_reloaded;
public class App extends Application implements HasActivityInjector {
//region Injected fields
@Inject
public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
//endregion
//region Fields
private ComponentApp mComponentApp;
//endregion
//region Lifecycle
@Override
public void onCreate() {
super.onCreate();
buildComponent();
mComponentApp.inject(this);
}
//endregion
//region DI setup
private void buildComponent() {
mComponentApp = DaggerComponentApp.builder()
.application(this)
|
.moduleApp(new ModuleApp(this))
|
RoRoche/AndroidModularReloaded
|
app/src/androidTest/java/fr/guddy/android_modular_reloaded/rules/AppTestRule.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
// public class App extends Application implements HasActivityInjector {
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
// //endregion
//
// //region Fields
// private ComponentApp mComponentApp;
// //endregion
//
// //region Lifecycle
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponent();
// mComponentApp.inject(this);
// }
// //endregion
//
// //region DI setup
// private void buildComponent() {
// mComponentApp = DaggerComponentApp.builder()
// .application(this)
// .moduleApp(new ModuleApp(this))
// .build();
// }
//
// @VisibleForTesting
// public void setComponentApp(@NonNull final ComponentApp pComponentApp) {
// mComponentApp = pComponentApp;
// }
// //endregion
//
// //region HasActivityInjector
// @Override
// public AndroidInjector<Activity> activityInjector() {
// return dispatchingActivityInjector;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleApp.class,
// ModuleMainActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final App pApp);
//
// Builder moduleApp(final ModuleApp pModuleApp);
//
// Builder moduleMainActivity(final ModuleMainActivity pModuleMainActivity);
//
// ComponentApp build();
// }
//
// void inject(final App pApp);
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
// @Module
// public class ModuleApp {
// //region Field
// private final App mApp;
// //endregion
//
// //region Constructor
// public ModuleApp(@NonNull final App pApp) {
// mApp = pApp;
// }
// //endregion
//
// //region Provides
// @Singleton
// @Provides
// public App providesApp() {
// return mApp;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleMainActivity.java
// @Module
// public class ModuleMainActivity {
// //region Provides
// @Provides
// public IDateFormatter providesDateFormatter() {
// return new DateFormatter();
// }
// //endregion
// }
|
import android.support.test.InstrumentationRegistry;
import fr.guddy.android_modular_reloaded.App;
import fr.guddy.android_modular_reloaded.di.ComponentApp;
import fr.guddy.android_modular_reloaded.di.ModuleApp;
import fr.guddy.android_modular_reloaded.di.ModuleMainActivity;
import it.cosenonjaviste.daggermock.DaggerMockRule;
|
package fr.guddy.android_modular_reloaded.rules;
public class AppTestRule extends DaggerMockRule<ComponentApp> {
//region Constructor
public AppTestRule() {
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
// public class App extends Application implements HasActivityInjector {
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
// //endregion
//
// //region Fields
// private ComponentApp mComponentApp;
// //endregion
//
// //region Lifecycle
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponent();
// mComponentApp.inject(this);
// }
// //endregion
//
// //region DI setup
// private void buildComponent() {
// mComponentApp = DaggerComponentApp.builder()
// .application(this)
// .moduleApp(new ModuleApp(this))
// .build();
// }
//
// @VisibleForTesting
// public void setComponentApp(@NonNull final ComponentApp pComponentApp) {
// mComponentApp = pComponentApp;
// }
// //endregion
//
// //region HasActivityInjector
// @Override
// public AndroidInjector<Activity> activityInjector() {
// return dispatchingActivityInjector;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleApp.class,
// ModuleMainActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final App pApp);
//
// Builder moduleApp(final ModuleApp pModuleApp);
//
// Builder moduleMainActivity(final ModuleMainActivity pModuleMainActivity);
//
// ComponentApp build();
// }
//
// void inject(final App pApp);
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
// @Module
// public class ModuleApp {
// //region Field
// private final App mApp;
// //endregion
//
// //region Constructor
// public ModuleApp(@NonNull final App pApp) {
// mApp = pApp;
// }
// //endregion
//
// //region Provides
// @Singleton
// @Provides
// public App providesApp() {
// return mApp;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleMainActivity.java
// @Module
// public class ModuleMainActivity {
// //region Provides
// @Provides
// public IDateFormatter providesDateFormatter() {
// return new DateFormatter();
// }
// //endregion
// }
// Path: app/src/androidTest/java/fr/guddy/android_modular_reloaded/rules/AppTestRule.java
import android.support.test.InstrumentationRegistry;
import fr.guddy.android_modular_reloaded.App;
import fr.guddy.android_modular_reloaded.di.ComponentApp;
import fr.guddy.android_modular_reloaded.di.ModuleApp;
import fr.guddy.android_modular_reloaded.di.ModuleMainActivity;
import it.cosenonjaviste.daggermock.DaggerMockRule;
package fr.guddy.android_modular_reloaded.rules;
public class AppTestRule extends DaggerMockRule<ComponentApp> {
//region Constructor
public AppTestRule() {
|
super(ComponentApp.class, new ModuleApp(getApp()), new ModuleMainActivity());
|
RoRoche/AndroidModularReloaded
|
app/src/androidTest/java/fr/guddy/android_modular_reloaded/rules/AppTestRule.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
// public class App extends Application implements HasActivityInjector {
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
// //endregion
//
// //region Fields
// private ComponentApp mComponentApp;
// //endregion
//
// //region Lifecycle
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponent();
// mComponentApp.inject(this);
// }
// //endregion
//
// //region DI setup
// private void buildComponent() {
// mComponentApp = DaggerComponentApp.builder()
// .application(this)
// .moduleApp(new ModuleApp(this))
// .build();
// }
//
// @VisibleForTesting
// public void setComponentApp(@NonNull final ComponentApp pComponentApp) {
// mComponentApp = pComponentApp;
// }
// //endregion
//
// //region HasActivityInjector
// @Override
// public AndroidInjector<Activity> activityInjector() {
// return dispatchingActivityInjector;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleApp.class,
// ModuleMainActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final App pApp);
//
// Builder moduleApp(final ModuleApp pModuleApp);
//
// Builder moduleMainActivity(final ModuleMainActivity pModuleMainActivity);
//
// ComponentApp build();
// }
//
// void inject(final App pApp);
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
// @Module
// public class ModuleApp {
// //region Field
// private final App mApp;
// //endregion
//
// //region Constructor
// public ModuleApp(@NonNull final App pApp) {
// mApp = pApp;
// }
// //endregion
//
// //region Provides
// @Singleton
// @Provides
// public App providesApp() {
// return mApp;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleMainActivity.java
// @Module
// public class ModuleMainActivity {
// //region Provides
// @Provides
// public IDateFormatter providesDateFormatter() {
// return new DateFormatter();
// }
// //endregion
// }
|
import android.support.test.InstrumentationRegistry;
import fr.guddy.android_modular_reloaded.App;
import fr.guddy.android_modular_reloaded.di.ComponentApp;
import fr.guddy.android_modular_reloaded.di.ModuleApp;
import fr.guddy.android_modular_reloaded.di.ModuleMainActivity;
import it.cosenonjaviste.daggermock.DaggerMockRule;
|
package fr.guddy.android_modular_reloaded.rules;
public class AppTestRule extends DaggerMockRule<ComponentApp> {
//region Constructor
public AppTestRule() {
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
// public class App extends Application implements HasActivityInjector {
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
// //endregion
//
// //region Fields
// private ComponentApp mComponentApp;
// //endregion
//
// //region Lifecycle
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponent();
// mComponentApp.inject(this);
// }
// //endregion
//
// //region DI setup
// private void buildComponent() {
// mComponentApp = DaggerComponentApp.builder()
// .application(this)
// .moduleApp(new ModuleApp(this))
// .build();
// }
//
// @VisibleForTesting
// public void setComponentApp(@NonNull final ComponentApp pComponentApp) {
// mComponentApp = pComponentApp;
// }
// //endregion
//
// //region HasActivityInjector
// @Override
// public AndroidInjector<Activity> activityInjector() {
// return dispatchingActivityInjector;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleApp.class,
// ModuleMainActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final App pApp);
//
// Builder moduleApp(final ModuleApp pModuleApp);
//
// Builder moduleMainActivity(final ModuleMainActivity pModuleMainActivity);
//
// ComponentApp build();
// }
//
// void inject(final App pApp);
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
// @Module
// public class ModuleApp {
// //region Field
// private final App mApp;
// //endregion
//
// //region Constructor
// public ModuleApp(@NonNull final App pApp) {
// mApp = pApp;
// }
// //endregion
//
// //region Provides
// @Singleton
// @Provides
// public App providesApp() {
// return mApp;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleMainActivity.java
// @Module
// public class ModuleMainActivity {
// //region Provides
// @Provides
// public IDateFormatter providesDateFormatter() {
// return new DateFormatter();
// }
// //endregion
// }
// Path: app/src/androidTest/java/fr/guddy/android_modular_reloaded/rules/AppTestRule.java
import android.support.test.InstrumentationRegistry;
import fr.guddy.android_modular_reloaded.App;
import fr.guddy.android_modular_reloaded.di.ComponentApp;
import fr.guddy.android_modular_reloaded.di.ModuleApp;
import fr.guddy.android_modular_reloaded.di.ModuleMainActivity;
import it.cosenonjaviste.daggermock.DaggerMockRule;
package fr.guddy.android_modular_reloaded.rules;
public class AppTestRule extends DaggerMockRule<ComponentApp> {
//region Constructor
public AppTestRule() {
|
super(ComponentApp.class, new ModuleApp(getApp()), new ModuleMainActivity());
|
RoRoche/AndroidModularReloaded
|
app/src/androidTest/java/fr/guddy/android_modular_reloaded/rules/AppTestRule.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
// public class App extends Application implements HasActivityInjector {
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
// //endregion
//
// //region Fields
// private ComponentApp mComponentApp;
// //endregion
//
// //region Lifecycle
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponent();
// mComponentApp.inject(this);
// }
// //endregion
//
// //region DI setup
// private void buildComponent() {
// mComponentApp = DaggerComponentApp.builder()
// .application(this)
// .moduleApp(new ModuleApp(this))
// .build();
// }
//
// @VisibleForTesting
// public void setComponentApp(@NonNull final ComponentApp pComponentApp) {
// mComponentApp = pComponentApp;
// }
// //endregion
//
// //region HasActivityInjector
// @Override
// public AndroidInjector<Activity> activityInjector() {
// return dispatchingActivityInjector;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleApp.class,
// ModuleMainActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final App pApp);
//
// Builder moduleApp(final ModuleApp pModuleApp);
//
// Builder moduleMainActivity(final ModuleMainActivity pModuleMainActivity);
//
// ComponentApp build();
// }
//
// void inject(final App pApp);
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
// @Module
// public class ModuleApp {
// //region Field
// private final App mApp;
// //endregion
//
// //region Constructor
// public ModuleApp(@NonNull final App pApp) {
// mApp = pApp;
// }
// //endregion
//
// //region Provides
// @Singleton
// @Provides
// public App providesApp() {
// return mApp;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleMainActivity.java
// @Module
// public class ModuleMainActivity {
// //region Provides
// @Provides
// public IDateFormatter providesDateFormatter() {
// return new DateFormatter();
// }
// //endregion
// }
|
import android.support.test.InstrumentationRegistry;
import fr.guddy.android_modular_reloaded.App;
import fr.guddy.android_modular_reloaded.di.ComponentApp;
import fr.guddy.android_modular_reloaded.di.ModuleApp;
import fr.guddy.android_modular_reloaded.di.ModuleMainActivity;
import it.cosenonjaviste.daggermock.DaggerMockRule;
|
package fr.guddy.android_modular_reloaded.rules;
public class AppTestRule extends DaggerMockRule<ComponentApp> {
//region Constructor
public AppTestRule() {
super(ComponentApp.class, new ModuleApp(getApp()), new ModuleMainActivity());
customizeBuilder(new BuilderCustomizer<ComponentApp.Builder>() {
@Override
public ComponentApp.Builder customize(final ComponentApp.Builder pBuilder) {
return pBuilder.application(getApp());
}
});
set((final ComponentApp pComponent) ->
pComponent.inject(getApp())
);
}
//endregion
//region Inner job
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
// public class App extends Application implements HasActivityInjector {
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
// //endregion
//
// //region Fields
// private ComponentApp mComponentApp;
// //endregion
//
// //region Lifecycle
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponent();
// mComponentApp.inject(this);
// }
// //endregion
//
// //region DI setup
// private void buildComponent() {
// mComponentApp = DaggerComponentApp.builder()
// .application(this)
// .moduleApp(new ModuleApp(this))
// .build();
// }
//
// @VisibleForTesting
// public void setComponentApp(@NonNull final ComponentApp pComponentApp) {
// mComponentApp = pComponentApp;
// }
// //endregion
//
// //region HasActivityInjector
// @Override
// public AndroidInjector<Activity> activityInjector() {
// return dispatchingActivityInjector;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleApp.class,
// ModuleMainActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final App pApp);
//
// Builder moduleApp(final ModuleApp pModuleApp);
//
// Builder moduleMainActivity(final ModuleMainActivity pModuleMainActivity);
//
// ComponentApp build();
// }
//
// void inject(final App pApp);
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
// @Module
// public class ModuleApp {
// //region Field
// private final App mApp;
// //endregion
//
// //region Constructor
// public ModuleApp(@NonNull final App pApp) {
// mApp = pApp;
// }
// //endregion
//
// //region Provides
// @Singleton
// @Provides
// public App providesApp() {
// return mApp;
// }
// //endregion
// }
//
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleMainActivity.java
// @Module
// public class ModuleMainActivity {
// //region Provides
// @Provides
// public IDateFormatter providesDateFormatter() {
// return new DateFormatter();
// }
// //endregion
// }
// Path: app/src/androidTest/java/fr/guddy/android_modular_reloaded/rules/AppTestRule.java
import android.support.test.InstrumentationRegistry;
import fr.guddy.android_modular_reloaded.App;
import fr.guddy.android_modular_reloaded.di.ComponentApp;
import fr.guddy.android_modular_reloaded.di.ModuleApp;
import fr.guddy.android_modular_reloaded.di.ModuleMainActivity;
import it.cosenonjaviste.daggermock.DaggerMockRule;
package fr.guddy.android_modular_reloaded.rules;
public class AppTestRule extends DaggerMockRule<ComponentApp> {
//region Constructor
public AppTestRule() {
super(ComponentApp.class, new ModuleApp(getApp()), new ModuleMainActivity());
customizeBuilder(new BuilderCustomizer<ComponentApp.Builder>() {
@Override
public ComponentApp.Builder customize(final ComponentApp.Builder pBuilder) {
return pBuilder.application(getApp());
}
});
set((final ComponentApp pComponent) ->
pComponent.inject(getApp())
);
}
//endregion
//region Inner job
|
private static App getApp() {
|
RoRoche/AndroidModularReloaded
|
second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ComponentDebugActivity.java
|
// Path: debugutils/src/main/java/fr/guddy/android_modular_reloaded/debugutils/DebugActivity.java
// public class DebugActivity extends AppCompatActivity implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
// }
|
import dagger.Subcomponent;
import dagger.android.AndroidInjector;
import fr.guddy.android_modular_reloaded.debugutils.DebugActivity;
|
package fr.guddy.android_modular_reloaded.second.di;
@Subcomponent(modules = {
ModuleDebugActivity.class,
ModuleFragmentSecond.class
})
|
// Path: debugutils/src/main/java/fr/guddy/android_modular_reloaded/debugutils/DebugActivity.java
// public class DebugActivity extends AppCompatActivity implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
// }
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ComponentDebugActivity.java
import dagger.Subcomponent;
import dagger.android.AndroidInjector;
import fr.guddy.android_modular_reloaded.debugutils.DebugActivity;
package fr.guddy.android_modular_reloaded.second.di;
@Subcomponent(modules = {
ModuleDebugActivity.class,
ModuleFragmentSecond.class
})
|
public interface ComponentDebugActivity extends AndroidInjector<DebugActivity> {
|
RoRoche/AndroidModularReloaded
|
app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
// public class App extends Application implements HasActivityInjector {
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
// //endregion
//
// //region Fields
// private ComponentApp mComponentApp;
// //endregion
//
// //region Lifecycle
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponent();
// mComponentApp.inject(this);
// }
// //endregion
//
// //region DI setup
// private void buildComponent() {
// mComponentApp = DaggerComponentApp.builder()
// .application(this)
// .moduleApp(new ModuleApp(this))
// .build();
// }
//
// @VisibleForTesting
// public void setComponentApp(@NonNull final ComponentApp pComponentApp) {
// mComponentApp = pComponentApp;
// }
// //endregion
//
// //region HasActivityInjector
// @Override
// public AndroidInjector<Activity> activityInjector() {
// return dispatchingActivityInjector;
// }
// //endregion
// }
|
import javax.inject.Singleton;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.support.AndroidSupportInjectionModule;
import fr.guddy.android_modular_reloaded.App;
|
package fr.guddy.android_modular_reloaded.di;
@Singleton
@Component(modules = {
AndroidSupportInjectionModule.class,
ModuleApp.class,
ModuleMainActivity.class,
ActivityBindingModule.class,
})
public interface ComponentApp {
@Component.Builder
interface Builder {
@BindsInstance
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
// public class App extends Application implements HasActivityInjector {
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
// //endregion
//
// //region Fields
// private ComponentApp mComponentApp;
// //endregion
//
// //region Lifecycle
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponent();
// mComponentApp.inject(this);
// }
// //endregion
//
// //region DI setup
// private void buildComponent() {
// mComponentApp = DaggerComponentApp.builder()
// .application(this)
// .moduleApp(new ModuleApp(this))
// .build();
// }
//
// @VisibleForTesting
// public void setComponentApp(@NonNull final ComponentApp pComponentApp) {
// mComponentApp = pComponentApp;
// }
// //endregion
//
// //region HasActivityInjector
// @Override
// public AndroidInjector<Activity> activityInjector() {
// return dispatchingActivityInjector;
// }
// //endregion
// }
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ComponentApp.java
import javax.inject.Singleton;
import dagger.BindsInstance;
import dagger.Component;
import dagger.android.support.AndroidSupportInjectionModule;
import fr.guddy.android_modular_reloaded.App;
package fr.guddy.android_modular_reloaded.di;
@Singleton
@Component(modules = {
AndroidSupportInjectionModule.class,
ModuleApp.class,
ModuleMainActivity.class,
ActivityBindingModule.class,
})
public interface ComponentApp {
@Component.Builder
interface Builder {
@BindsInstance
|
Builder application(final App pApp);
|
RoRoche/AndroidModularReloaded
|
second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ActivityBindingModule.java
|
// Path: debugutils/src/main/java/fr/guddy/android_modular_reloaded/debugutils/DebugActivity.java
// public class DebugActivity extends AppCompatActivity implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
// }
|
import android.app.Activity;
import dagger.Binds;
import dagger.Module;
import dagger.android.ActivityKey;
import dagger.android.AndroidInjector;
import dagger.multibindings.IntoMap;
import fr.guddy.android_modular_reloaded.debugutils.DebugActivity;
|
package fr.guddy.android_modular_reloaded.second.di;
@Module(subcomponents = {
ComponentDebugActivity.class
})
public abstract class ActivityBindingModule {
@Binds
@IntoMap
|
// Path: debugutils/src/main/java/fr/guddy/android_modular_reloaded/debugutils/DebugActivity.java
// public class DebugActivity extends AppCompatActivity implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
// }
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ActivityBindingModule.java
import android.app.Activity;
import dagger.Binds;
import dagger.Module;
import dagger.android.ActivityKey;
import dagger.android.AndroidInjector;
import dagger.multibindings.IntoMap;
import fr.guddy.android_modular_reloaded.debugutils.DebugActivity;
package fr.guddy.android_modular_reloaded.second.di;
@Module(subcomponents = {
ComponentDebugActivity.class
})
public abstract class ActivityBindingModule {
@Binds
@IntoMap
|
@ActivityKey(DebugActivity.class)
|
RoRoche/AndroidModularReloaded
|
second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/rules/AppTestRule.java
|
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/DebugApp.java
// public class DebugApp extends AbstractDebugApp {
//
// //region AbstractDebugApp overridden method
// @Override
// protected void buildComponentAndInjectThis() {
// DaggerComponentDebugApp.builder()
// .application(this)
// .build()
// .inject(this);
// }
// //endregion
// }
//
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ComponentDebugApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleDebugActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentDebugApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final DebugApp pDebugApp);
//
// Builder moduleDebugActivity(final ModuleDebugActivity pModuleDebugActivity);
//
// ComponentDebugApp build();
// }
//
// void inject(final DebugApp pApp);
// }
//
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ModuleDebugActivity.java
// @Module
// public class ModuleDebugActivity {
// //region Provides
// @Provides
// public IDateFormatter providesDateFormatter() {
// return null;
// }
// //endregion
// }
|
import android.support.test.InstrumentationRegistry;
import fr.guddy.android_modular_reloaded.second.DebugApp;
import fr.guddy.android_modular_reloaded.second.di.ComponentDebugApp;
import fr.guddy.android_modular_reloaded.second.di.ModuleDebugActivity;
import it.cosenonjaviste.daggermock.DaggerMockRule;
|
package fr.guddy.android_modular_reloaded.second.rules;
public class AppTestRule extends DaggerMockRule<ComponentDebugApp> {
//region Constructor
public AppTestRule() {
|
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/DebugApp.java
// public class DebugApp extends AbstractDebugApp {
//
// //region AbstractDebugApp overridden method
// @Override
// protected void buildComponentAndInjectThis() {
// DaggerComponentDebugApp.builder()
// .application(this)
// .build()
// .inject(this);
// }
// //endregion
// }
//
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ComponentDebugApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleDebugActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentDebugApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final DebugApp pDebugApp);
//
// Builder moduleDebugActivity(final ModuleDebugActivity pModuleDebugActivity);
//
// ComponentDebugApp build();
// }
//
// void inject(final DebugApp pApp);
// }
//
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ModuleDebugActivity.java
// @Module
// public class ModuleDebugActivity {
// //region Provides
// @Provides
// public IDateFormatter providesDateFormatter() {
// return null;
// }
// //endregion
// }
// Path: second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/rules/AppTestRule.java
import android.support.test.InstrumentationRegistry;
import fr.guddy.android_modular_reloaded.second.DebugApp;
import fr.guddy.android_modular_reloaded.second.di.ComponentDebugApp;
import fr.guddy.android_modular_reloaded.second.di.ModuleDebugActivity;
import it.cosenonjaviste.daggermock.DaggerMockRule;
package fr.guddy.android_modular_reloaded.second.rules;
public class AppTestRule extends DaggerMockRule<ComponentDebugApp> {
//region Constructor
public AppTestRule() {
|
super(ComponentDebugApp.class, new ModuleDebugActivity());
|
RoRoche/AndroidModularReloaded
|
second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/rules/AppTestRule.java
|
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/DebugApp.java
// public class DebugApp extends AbstractDebugApp {
//
// //region AbstractDebugApp overridden method
// @Override
// protected void buildComponentAndInjectThis() {
// DaggerComponentDebugApp.builder()
// .application(this)
// .build()
// .inject(this);
// }
// //endregion
// }
//
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ComponentDebugApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleDebugActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentDebugApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final DebugApp pDebugApp);
//
// Builder moduleDebugActivity(final ModuleDebugActivity pModuleDebugActivity);
//
// ComponentDebugApp build();
// }
//
// void inject(final DebugApp pApp);
// }
//
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ModuleDebugActivity.java
// @Module
// public class ModuleDebugActivity {
// //region Provides
// @Provides
// public IDateFormatter providesDateFormatter() {
// return null;
// }
// //endregion
// }
|
import android.support.test.InstrumentationRegistry;
import fr.guddy.android_modular_reloaded.second.DebugApp;
import fr.guddy.android_modular_reloaded.second.di.ComponentDebugApp;
import fr.guddy.android_modular_reloaded.second.di.ModuleDebugActivity;
import it.cosenonjaviste.daggermock.DaggerMockRule;
|
package fr.guddy.android_modular_reloaded.second.rules;
public class AppTestRule extends DaggerMockRule<ComponentDebugApp> {
//region Constructor
public AppTestRule() {
super(ComponentDebugApp.class, new ModuleDebugActivity());
customizeBuilder(new BuilderCustomizer<ComponentDebugApp.Builder>() {
@Override
public ComponentDebugApp.Builder customize(final ComponentDebugApp.Builder pBuilder) {
return pBuilder.application(getApp());
}
});
set((final ComponentDebugApp pComponent) ->
pComponent.inject(getApp())
);
}
//endregion
//region Inner job
|
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/DebugApp.java
// public class DebugApp extends AbstractDebugApp {
//
// //region AbstractDebugApp overridden method
// @Override
// protected void buildComponentAndInjectThis() {
// DaggerComponentDebugApp.builder()
// .application(this)
// .build()
// .inject(this);
// }
// //endregion
// }
//
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ComponentDebugApp.java
// @Singleton
// @Component(modules = {
// AndroidSupportInjectionModule.class,
// ModuleDebugActivity.class,
// ActivityBindingModule.class,
// })
// public interface ComponentDebugApp {
// @Component.Builder
// interface Builder {
// @BindsInstance
// Builder application(final DebugApp pDebugApp);
//
// Builder moduleDebugActivity(final ModuleDebugActivity pModuleDebugActivity);
//
// ComponentDebugApp build();
// }
//
// void inject(final DebugApp pApp);
// }
//
// Path: second/src/debug/java/fr/guddy/android_modular_reloaded/second/di/ModuleDebugActivity.java
// @Module
// public class ModuleDebugActivity {
// //region Provides
// @Provides
// public IDateFormatter providesDateFormatter() {
// return null;
// }
// //endregion
// }
// Path: second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/rules/AppTestRule.java
import android.support.test.InstrumentationRegistry;
import fr.guddy.android_modular_reloaded.second.DebugApp;
import fr.guddy.android_modular_reloaded.second.di.ComponentDebugApp;
import fr.guddy.android_modular_reloaded.second.di.ModuleDebugActivity;
import it.cosenonjaviste.daggermock.DaggerMockRule;
package fr.guddy.android_modular_reloaded.second.rules;
public class AppTestRule extends DaggerMockRule<ComponentDebugApp> {
//region Constructor
public AppTestRule() {
super(ComponentDebugApp.class, new ModuleDebugActivity());
customizeBuilder(new BuilderCustomizer<ComponentDebugApp.Builder>() {
@Override
public ComponentDebugApp.Builder customize(final ComponentDebugApp.Builder pBuilder) {
return pBuilder.application(getApp());
}
});
set((final ComponentDebugApp pComponent) ->
pComponent.inject(getApp())
);
}
//endregion
//region Inner job
|
private static DebugApp getApp() {
|
RoRoche/AndroidModularReloaded
|
app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
// public class App extends Application implements HasActivityInjector {
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
// //endregion
//
// //region Fields
// private ComponentApp mComponentApp;
// //endregion
//
// //region Lifecycle
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponent();
// mComponentApp.inject(this);
// }
// //endregion
//
// //region DI setup
// private void buildComponent() {
// mComponentApp = DaggerComponentApp.builder()
// .application(this)
// .moduleApp(new ModuleApp(this))
// .build();
// }
//
// @VisibleForTesting
// public void setComponentApp(@NonNull final ComponentApp pComponentApp) {
// mComponentApp = pComponentApp;
// }
// //endregion
//
// //region HasActivityInjector
// @Override
// public AndroidInjector<Activity> activityInjector() {
// return dispatchingActivityInjector;
// }
// //endregion
// }
|
import android.support.annotation.NonNull;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import fr.guddy.android_modular_reloaded.App;
|
package fr.guddy.android_modular_reloaded.di;
@Module
public class ModuleApp {
//region Field
|
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/App.java
// public class App extends Application implements HasActivityInjector {
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Activity> dispatchingActivityInjector;
// //endregion
//
// //region Fields
// private ComponentApp mComponentApp;
// //endregion
//
// //region Lifecycle
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponent();
// mComponentApp.inject(this);
// }
// //endregion
//
// //region DI setup
// private void buildComponent() {
// mComponentApp = DaggerComponentApp.builder()
// .application(this)
// .moduleApp(new ModuleApp(this))
// .build();
// }
//
// @VisibleForTesting
// public void setComponentApp(@NonNull final ComponentApp pComponentApp) {
// mComponentApp = pComponentApp;
// }
// //endregion
//
// //region HasActivityInjector
// @Override
// public AndroidInjector<Activity> activityInjector() {
// return dispatchingActivityInjector;
// }
// //endregion
// }
// Path: app/src/main/java/fr/guddy/android_modular_reloaded/di/ModuleApp.java
import android.support.annotation.NonNull;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import fr.guddy.android_modular_reloaded.App;
package fr.guddy.android_modular_reloaded.di;
@Module
public class ModuleApp {
//region Field
|
private final App mApp;
|
RoRoche/AndroidModularReloaded
|
second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/FragmentSecondTest.java
|
// Path: debugutils/src/main/java/fr/guddy/android_modular_reloaded/debugutils/DebugActivity.java
// public class DebugActivity extends AppCompatActivity implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
// }
//
// Path: second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/rules/AppTestRule.java
// public class AppTestRule extends DaggerMockRule<ComponentDebugApp> {
// //region Constructor
// public AppTestRule() {
// super(ComponentDebugApp.class, new ModuleDebugActivity());
// customizeBuilder(new BuilderCustomizer<ComponentDebugApp.Builder>() {
// @Override
// public ComponentDebugApp.Builder customize(final ComponentDebugApp.Builder pBuilder) {
// return pBuilder.application(getApp());
// }
// });
// set((final ComponentDebugApp pComponent) ->
// pComponent.inject(getApp())
// );
// }
// //endregion
//
// //region Inner job
// private static DebugApp getApp() {
// return (DebugApp) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
// }
// //endregion
// }
|
import com.android21buttons.fragmenttestrule.FragmentTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import fr.guddy.android_modular_reloaded.debugutils.DebugActivity;
import fr.guddy.android_modular_reloaded.second.rules.AppTestRule;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
|
package fr.guddy.android_modular_reloaded.second;
public class FragmentSecondTest {
//region Rules
@Rule
|
// Path: debugutils/src/main/java/fr/guddy/android_modular_reloaded/debugutils/DebugActivity.java
// public class DebugActivity extends AppCompatActivity implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
// }
//
// Path: second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/rules/AppTestRule.java
// public class AppTestRule extends DaggerMockRule<ComponentDebugApp> {
// //region Constructor
// public AppTestRule() {
// super(ComponentDebugApp.class, new ModuleDebugActivity());
// customizeBuilder(new BuilderCustomizer<ComponentDebugApp.Builder>() {
// @Override
// public ComponentDebugApp.Builder customize(final ComponentDebugApp.Builder pBuilder) {
// return pBuilder.application(getApp());
// }
// });
// set((final ComponentDebugApp pComponent) ->
// pComponent.inject(getApp())
// );
// }
// //endregion
//
// //region Inner job
// private static DebugApp getApp() {
// return (DebugApp) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
// }
// //endregion
// }
// Path: second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/FragmentSecondTest.java
import com.android21buttons.fragmenttestrule.FragmentTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import fr.guddy.android_modular_reloaded.debugutils.DebugActivity;
import fr.guddy.android_modular_reloaded.second.rules.AppTestRule;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
package fr.guddy.android_modular_reloaded.second;
public class FragmentSecondTest {
//region Rules
@Rule
|
public FragmentTestRule<DebugActivity, FragmentSecond> fragmentTestRule =
|
RoRoche/AndroidModularReloaded
|
second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/FragmentSecondTest.java
|
// Path: debugutils/src/main/java/fr/guddy/android_modular_reloaded/debugutils/DebugActivity.java
// public class DebugActivity extends AppCompatActivity implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
// }
//
// Path: second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/rules/AppTestRule.java
// public class AppTestRule extends DaggerMockRule<ComponentDebugApp> {
// //region Constructor
// public AppTestRule() {
// super(ComponentDebugApp.class, new ModuleDebugActivity());
// customizeBuilder(new BuilderCustomizer<ComponentDebugApp.Builder>() {
// @Override
// public ComponentDebugApp.Builder customize(final ComponentDebugApp.Builder pBuilder) {
// return pBuilder.application(getApp());
// }
// });
// set((final ComponentDebugApp pComponent) ->
// pComponent.inject(getApp())
// );
// }
// //endregion
//
// //region Inner job
// private static DebugApp getApp() {
// return (DebugApp) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
// }
// //endregion
// }
|
import com.android21buttons.fragmenttestrule.FragmentTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import fr.guddy.android_modular_reloaded.debugutils.DebugActivity;
import fr.guddy.android_modular_reloaded.second.rules.AppTestRule;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
|
package fr.guddy.android_modular_reloaded.second;
public class FragmentSecondTest {
//region Rules
@Rule
public FragmentTestRule<DebugActivity, FragmentSecond> fragmentTestRule =
new FragmentTestRule<>(DebugActivity.class, FragmentSecond.class, false ,false);
@Rule
|
// Path: debugutils/src/main/java/fr/guddy/android_modular_reloaded/debugutils/DebugActivity.java
// public class DebugActivity extends AppCompatActivity implements HasSupportFragmentInjector {
//
// //region Injected fields
// @Inject
// public DispatchingAndroidInjector<Fragment> supportFragmentInjector;
// //endregion
//
// //region Lifecycle
// @Override
// protected void onCreate(final Bundle pSavedInstanceState) {
// AndroidInjection.inject(this);
// super.onCreate(pSavedInstanceState);
// }
// //endregion
//
// //region HasSupportFragmentInjector
// @Override
// public AndroidInjector<Fragment> supportFragmentInjector() {
// return supportFragmentInjector;
// }
// //endregion
// }
//
// Path: second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/rules/AppTestRule.java
// public class AppTestRule extends DaggerMockRule<ComponentDebugApp> {
// //region Constructor
// public AppTestRule() {
// super(ComponentDebugApp.class, new ModuleDebugActivity());
// customizeBuilder(new BuilderCustomizer<ComponentDebugApp.Builder>() {
// @Override
// public ComponentDebugApp.Builder customize(final ComponentDebugApp.Builder pBuilder) {
// return pBuilder.application(getApp());
// }
// });
// set((final ComponentDebugApp pComponent) ->
// pComponent.inject(getApp())
// );
// }
// //endregion
//
// //region Inner job
// private static DebugApp getApp() {
// return (DebugApp) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
// }
// //endregion
// }
// Path: second/src/androidTest/java/fr/guddy/android_modular_reloaded/second/FragmentSecondTest.java
import com.android21buttons.fragmenttestrule.FragmentTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import fr.guddy.android_modular_reloaded.debugutils.DebugActivity;
import fr.guddy.android_modular_reloaded.second.rules.AppTestRule;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
package fr.guddy.android_modular_reloaded.second;
public class FragmentSecondTest {
//region Rules
@Rule
public FragmentTestRule<DebugActivity, FragmentSecond> fragmentTestRule =
new FragmentTestRule<>(DebugActivity.class, FragmentSecond.class, false ,false);
@Rule
|
public AppTestRule mRule = new AppTestRule();
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationAutreObjet.java
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
|
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.specification.Specification;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.specification.objet;
public class SpecificationAutreObjet<T> implements Specification<T> {
public SpecificationAutreObjet(T objetSpécifié) {
this.objetSpécifié = objetSpécifié;
}
@Override
public boolean estSatisfaitePar(T objet) {
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationAutreObjet.java
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.specification.Specification;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.specification.objet;
public class SpecificationAutreObjet<T> implements Specification<T> {
public SpecificationAutreObjet(T objetSpécifié) {
this.objetSpécifié = objetSpécifié;
}
@Override
public boolean estSatisfaitePar(T objet) {
|
return !Objets.egaux(objetSpécifié, objet);
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/specification/Specification.java
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/FabriqueSpecification.java
// public class FabriqueSpecification {
//
// public <T> Specification<T> combine(Specification<? super T> spécification,
// Specification<? super T> autreSpécification) {
// return new Specification<T>() {
// @Override
// public boolean estSatisfaitePar(T objet) {
// return spécification.estSatisfaitePar(objet) && autreSpécification.estSatisfaitePar(objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// if (!spécification.estSatisfaitePar(objet)) {
// return spécification.messageInsatisfactionPour(objet);
// }
// return autreSpécification.messageInsatisfactionPour(objet);
// }
// };
// }
// }
|
import java.util.Objects;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.FabriqueSpecification;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.specification;
/**
* Représente une spécification d'un objet.
*
* @param <T> le type d'objet concerné.
*/
@FunctionalInterface
public interface Specification<T> {
/**
* Informe si la spécification n'est pas satisfaite par l'objet.
*
* @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
* @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
*/
boolean estSatisfaitePar(T objet);
/**
* Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
*
* @param objet l'objet qui ne satisfait pas la spécification.
* @return le message décrivant pourquoi la spécification n'est pas satisfaite.
*/
default String messageInsatisfactionPour(T objet) {
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/FabriqueSpecification.java
// public class FabriqueSpecification {
//
// public <T> Specification<T> combine(Specification<? super T> spécification,
// Specification<? super T> autreSpécification) {
// return new Specification<T>() {
// @Override
// public boolean estSatisfaitePar(T objet) {
// return spécification.estSatisfaitePar(objet) && autreSpécification.estSatisfaitePar(objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// if (!spécification.estSatisfaitePar(objet)) {
// return spécification.messageInsatisfactionPour(objet);
// }
// return autreSpécification.messageInsatisfactionPour(objet);
// }
// };
// }
// }
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
import java.util.Objects;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.FabriqueSpecification;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.specification;
/**
* Représente une spécification d'un objet.
*
* @param <T> le type d'objet concerné.
*/
@FunctionalInterface
public interface Specification<T> {
/**
* Informe si la spécification n'est pas satisfaite par l'objet.
*
* @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
* @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
*/
boolean estSatisfaitePar(T objet);
/**
* Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
*
* @param objet l'objet qui ne satisfait pas la spécification.
* @return le message décrivant pourquoi la spécification n'est pas satisfaite.
*/
default String messageInsatisfactionPour(T objet) {
|
return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/specification/Specification.java
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/FabriqueSpecification.java
// public class FabriqueSpecification {
//
// public <T> Specification<T> combine(Specification<? super T> spécification,
// Specification<? super T> autreSpécification) {
// return new Specification<T>() {
// @Override
// public boolean estSatisfaitePar(T objet) {
// return spécification.estSatisfaitePar(objet) && autreSpécification.estSatisfaitePar(objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// if (!spécification.estSatisfaitePar(objet)) {
// return spécification.messageInsatisfactionPour(objet);
// }
// return autreSpécification.messageInsatisfactionPour(objet);
// }
// };
// }
// }
|
import java.util.Objects;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.FabriqueSpecification;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.specification;
/**
* Représente une spécification d'un objet.
*
* @param <T> le type d'objet concerné.
*/
@FunctionalInterface
public interface Specification<T> {
/**
* Informe si la spécification n'est pas satisfaite par l'objet.
*
* @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
* @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
*/
boolean estSatisfaitePar(T objet);
/**
* Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
*
* @param objet l'objet qui ne satisfait pas la spécification.
* @return le message décrivant pourquoi la spécification n'est pas satisfaite.
*/
default String messageInsatisfactionPour(T objet) {
return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
}
/**
* Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
* la combinaison le sont pour l'objet.
* Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
*
* @param autreSpécification l'autre spécification à combiner.
* @return la spécification combinée.
*/
default Specification<T> et(Specification<? super T> autreSpécification) {
Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/FabriqueSpecification.java
// public class FabriqueSpecification {
//
// public <T> Specification<T> combine(Specification<? super T> spécification,
// Specification<? super T> autreSpécification) {
// return new Specification<T>() {
// @Override
// public boolean estSatisfaitePar(T objet) {
// return spécification.estSatisfaitePar(objet) && autreSpécification.estSatisfaitePar(objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// if (!spécification.estSatisfaitePar(objet)) {
// return spécification.messageInsatisfactionPour(objet);
// }
// return autreSpécification.messageInsatisfactionPour(objet);
// }
// };
// }
// }
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
import java.util.Objects;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.FabriqueSpecification;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.specification;
/**
* Représente une spécification d'un objet.
*
* @param <T> le type d'objet concerné.
*/
@FunctionalInterface
public interface Specification<T> {
/**
* Informe si la spécification n'est pas satisfaite par l'objet.
*
* @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
* @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
*/
boolean estSatisfaitePar(T objet);
/**
* Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
*
* @param objet l'objet qui ne satisfait pas la spécification.
* @return le message décrivant pourquoi la spécification n'est pas satisfaite.
*/
default String messageInsatisfactionPour(T objet) {
return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
}
/**
* Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
* la combinaison le sont pour l'objet.
* Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
*
* @param autreSpécification l'autre spécification à combiner.
* @return la spécification combinée.
*/
default Specification<T> et(Specification<? super T> autreSpécification) {
Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
|
return new FabriqueSpecification().combine(this, autreSpécification);
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationObjet.java
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
|
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.specification.Specification;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.specification.objet;
public class SpecificationObjet<T> implements Specification<T> {
public SpecificationObjet(T objetSpécifié) {
this.objetSpécifié = objetSpécifié;
}
@Override
public boolean estSatisfaitePar(T objet) {
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationObjet.java
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.specification.Specification;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.specification.objet;
public class SpecificationObjet<T> implements Specification<T> {
public SpecificationObjet(T objetSpécifié) {
this.objetSpécifié = objetSpécifié;
}
@Override
public boolean estSatisfaitePar(T objet) {
|
return !Objets.différents(objetSpécifié, objet);
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/interne/injection/InjecteurDeBase.java
|
// Path: src/main/java/fr/arpinum/cocoritest/injection/Injecteur.java
// public interface Injecteur {
//
// /**
// * Injecte des dépendances à un objet.
// *
// * @param dépendances les dépendances à injecter.
// * @return l'injecteur pour pouvoir chaîner les injections.
// */
// Injecteur injecte(Object... dépendances);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Listes.java
// public class Listes {
//
// public static <E> List<E> cree() {
// return new ArrayList<>();
// }
//
// public static <E> List<E> cree(E élément) {
// List<E> liste = cree();
// liste.add(élément);
// return liste;
// }
//
// public static <E> List<E> cree(E élément, E élémentBis) {
// List<E> liste = cree(élément);
// liste.add(élémentBis);
// return liste;
// }
//
// public static <E> List<E> cree(E élément, E élémentBis, E élémentTer) {
// List<E> liste = cree(élément, élémentBis);
// liste.add(élémentTer);
// return liste;
// }
//
// public static <E> List<E> cree(E[] éléments) {
// List<E> liste = new ArrayList<>();
// java.util.Collections.addAll(liste, éléments);
// return liste;
// }
// }
|
import java.lang.reflect.Field;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import fr.arpinum.cocoritest.injection.Injecteur;
import fr.arpinum.cocoritest.interne.extensionlangage.Listes;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.injection;
public class InjecteurDeBase implements Injecteur {
public InjecteurDeBase(Object objet) {
this.objet = objet;
}
@Override
public Injecteur injecte(Object... dépendances) {
|
// Path: src/main/java/fr/arpinum/cocoritest/injection/Injecteur.java
// public interface Injecteur {
//
// /**
// * Injecte des dépendances à un objet.
// *
// * @param dépendances les dépendances à injecter.
// * @return l'injecteur pour pouvoir chaîner les injections.
// */
// Injecteur injecte(Object... dépendances);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Listes.java
// public class Listes {
//
// public static <E> List<E> cree() {
// return new ArrayList<>();
// }
//
// public static <E> List<E> cree(E élément) {
// List<E> liste = cree();
// liste.add(élément);
// return liste;
// }
//
// public static <E> List<E> cree(E élément, E élémentBis) {
// List<E> liste = cree(élément);
// liste.add(élémentBis);
// return liste;
// }
//
// public static <E> List<E> cree(E élément, E élémentBis, E élémentTer) {
// List<E> liste = cree(élément, élémentBis);
// liste.add(élémentTer);
// return liste;
// }
//
// public static <E> List<E> cree(E[] éléments) {
// List<E> liste = new ArrayList<>();
// java.util.Collections.addAll(liste, éléments);
// return liste;
// }
// }
// Path: src/main/java/fr/arpinum/cocoritest/interne/injection/InjecteurDeBase.java
import java.lang.reflect.Field;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import fr.arpinum.cocoritest.injection.Injecteur;
import fr.arpinum.cocoritest.interne.extensionlangage.Listes;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.injection;
public class InjecteurDeBase implements Injecteur {
public InjecteurDeBase(Object objet) {
this.objet = objet;
}
@Override
public Injecteur injecte(Object... dépendances) {
|
Listes.cree(dépendances).forEach(this::injecte);
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/affirmation/collection/AffirmationCollection.java
|
// Path: src/main/java/fr/arpinum/cocoritest/conjonction/Conjonction.java
// @FunctionalInterface
// public interface Conjonction<T> {
//
// T et();
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Listes.java
// public class Listes {
//
// public static <E> List<E> cree() {
// return new ArrayList<>();
// }
//
// public static <E> List<E> cree(E élément) {
// List<E> liste = cree();
// liste.add(élément);
// return liste;
// }
//
// public static <E> List<E> cree(E élément, E élémentBis) {
// List<E> liste = cree(élément);
// liste.add(élémentBis);
// return liste;
// }
//
// public static <E> List<E> cree(E élément, E élémentBis, E élémentTer) {
// List<E> liste = cree(élément, élémentBis);
// liste.add(élémentTer);
// return liste;
// }
//
// public static <E> List<E> cree(E[] éléments) {
// List<E> liste = new ArrayList<>();
// java.util.Collections.addAll(liste, éléments);
// return liste;
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
|
import java.util.Collection;
import fr.arpinum.cocoritest.conjonction.Conjonction;
import fr.arpinum.cocoritest.interne.extensionlangage.Listes;
import fr.arpinum.cocoritest.specification.Specification;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.affirmation.collection;
/**
* Représente une affirmation concernant une collection typée.
*
* @param <TElement> le type des éléments de la collection concernée par l'affirmation.
*/
public interface AffirmationCollection<TElement> {
/**
* Affirme que les éléments sont ceux attendus.
*
* @param élémentsAttendus les éléments attendus.
* @return une conjonction pour chaîner d'autres affirmations
* @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
*/
Conjonction<AffirmationCollection<TElement>> sont(Collection<TElement> élémentsAttendus);
/**
* Affirme que les éléments sont ceux attendus.
*
* @param élémentsAttendus les éléments attendus.
* @return une conjonction pour chaîner d'autres affirmations
* @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
*/
@SuppressWarnings("unchecked")
default Conjonction<AffirmationCollection<TElement>> sont(TElement... élémentsAttendus) {
|
// Path: src/main/java/fr/arpinum/cocoritest/conjonction/Conjonction.java
// @FunctionalInterface
// public interface Conjonction<T> {
//
// T et();
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Listes.java
// public class Listes {
//
// public static <E> List<E> cree() {
// return new ArrayList<>();
// }
//
// public static <E> List<E> cree(E élément) {
// List<E> liste = cree();
// liste.add(élément);
// return liste;
// }
//
// public static <E> List<E> cree(E élément, E élémentBis) {
// List<E> liste = cree(élément);
// liste.add(élémentBis);
// return liste;
// }
//
// public static <E> List<E> cree(E élément, E élémentBis, E élémentTer) {
// List<E> liste = cree(élément, élémentBis);
// liste.add(élémentTer);
// return liste;
// }
//
// public static <E> List<E> cree(E[] éléments) {
// List<E> liste = new ArrayList<>();
// java.util.Collections.addAll(liste, éléments);
// return liste;
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
// Path: src/main/java/fr/arpinum/cocoritest/affirmation/collection/AffirmationCollection.java
import java.util.Collection;
import fr.arpinum.cocoritest.conjonction.Conjonction;
import fr.arpinum.cocoritest.interne.extensionlangage.Listes;
import fr.arpinum.cocoritest.specification.Specification;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.affirmation.collection;
/**
* Représente une affirmation concernant une collection typée.
*
* @param <TElement> le type des éléments de la collection concernée par l'affirmation.
*/
public interface AffirmationCollection<TElement> {
/**
* Affirme que les éléments sont ceux attendus.
*
* @param élémentsAttendus les éléments attendus.
* @return une conjonction pour chaîner d'autres affirmations
* @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
*/
Conjonction<AffirmationCollection<TElement>> sont(Collection<TElement> élémentsAttendus);
/**
* Affirme que les éléments sont ceux attendus.
*
* @param élémentsAttendus les éléments attendus.
* @return une conjonction pour chaîner d'autres affirmations
* @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
*/
@SuppressWarnings("unchecked")
default Conjonction<AffirmationCollection<TElement>> sont(TElement... élémentsAttendus) {
|
return sont(Listes.cree(élémentsAttendus));
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/interne/affirmation/booleene/AffirmationBooleeneDeBase.java
|
// Path: src/main/java/fr/arpinum/cocoritest/affirmation/booleene/AffirmationBooleene.java
// public interface AffirmationBooleene {
//
// /**
// * Affirme que c'est vrai.
// *
// * @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
// */
// void estVrai();
//
// /**
// * Affirme que c'est faux.
// *
// * @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
// */
// void estFaux();
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/affirmation/booleene/AffirmationBooleeneAuFeminin.java
// public interface AffirmationBooleeneAuFeminin {
//
// /**
// * Affirme que c'est vrai.
// *
// * @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
// */
// void estVraie();
//
// /**
// * Affirme que c'est faux.
// *
// * @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
// */
// void estFausse();
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/Affirmation.java
// public class Affirmation {
//
// protected void échoue(String raison, Object... supplément) {
// throw new ExceptionAffirmation(String.format(raison, supplément));
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/objet/AffirmationObjetAuMasculinDeBase.java
// public class AffirmationObjetAuMasculinDeBase<TObjet> extends AffirmationObjetDeBase<TObjet,
// Conjonction<AffirmationObjetAuMasculin<TObjet>>> implements
// AffirmationObjetAuMasculin<TObjet> {
//
// public AffirmationObjetAuMasculinDeBase(TObjet objet) {
// super(objet);
// }
//
// @Override
// public Conjonction<AffirmationObjetAuMasculin<TObjet>> estNul() {
// return est(null);
// }
//
// @Override
// public Conjonction<AffirmationObjetAuMasculin<TObjet>> nEstPasNul() {
// return nEstPas(null);
// }
//
// @Override
// protected Conjonction<AffirmationObjetAuMasculin<TObjet>> créeConjonction() {
// return () -> this;
// }
// }
|
import fr.arpinum.cocoritest.affirmation.booleene.AffirmationBooleene;
import fr.arpinum.cocoritest.affirmation.booleene.AffirmationBooleeneAuFeminin;
import fr.arpinum.cocoritest.interne.affirmation.Affirmation;
import fr.arpinum.cocoritest.interne.affirmation.objet.AffirmationObjetAuMasculinDeBase;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.affirmation.booleene;
public class AffirmationBooleeneDeBase extends Affirmation implements AffirmationBooleene,
AffirmationBooleeneAuFeminin {
public AffirmationBooleeneDeBase(Boolean valeur) {
booléen = valeur;
}
@Override
public void estVrai() {
affirmeQueLeBooléenEst(true);
}
@Override
public void estVraie() {
estVrai();
}
@Override
public void estFaux() {
affirmeQueLeBooléenEst(false);
}
@Override
public void estFausse() {
estFaux();
}
private void affirmeQueLeBooléenEst(boolean attendue) {
|
// Path: src/main/java/fr/arpinum/cocoritest/affirmation/booleene/AffirmationBooleene.java
// public interface AffirmationBooleene {
//
// /**
// * Affirme que c'est vrai.
// *
// * @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
// */
// void estVrai();
//
// /**
// * Affirme que c'est faux.
// *
// * @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
// */
// void estFaux();
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/affirmation/booleene/AffirmationBooleeneAuFeminin.java
// public interface AffirmationBooleeneAuFeminin {
//
// /**
// * Affirme que c'est vrai.
// *
// * @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
// */
// void estVraie();
//
// /**
// * Affirme que c'est faux.
// *
// * @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
// */
// void estFausse();
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/Affirmation.java
// public class Affirmation {
//
// protected void échoue(String raison, Object... supplément) {
// throw new ExceptionAffirmation(String.format(raison, supplément));
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/objet/AffirmationObjetAuMasculinDeBase.java
// public class AffirmationObjetAuMasculinDeBase<TObjet> extends AffirmationObjetDeBase<TObjet,
// Conjonction<AffirmationObjetAuMasculin<TObjet>>> implements
// AffirmationObjetAuMasculin<TObjet> {
//
// public AffirmationObjetAuMasculinDeBase(TObjet objet) {
// super(objet);
// }
//
// @Override
// public Conjonction<AffirmationObjetAuMasculin<TObjet>> estNul() {
// return est(null);
// }
//
// @Override
// public Conjonction<AffirmationObjetAuMasculin<TObjet>> nEstPasNul() {
// return nEstPas(null);
// }
//
// @Override
// protected Conjonction<AffirmationObjetAuMasculin<TObjet>> créeConjonction() {
// return () -> this;
// }
// }
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/booleene/AffirmationBooleeneDeBase.java
import fr.arpinum.cocoritest.affirmation.booleene.AffirmationBooleene;
import fr.arpinum.cocoritest.affirmation.booleene.AffirmationBooleeneAuFeminin;
import fr.arpinum.cocoritest.interne.affirmation.Affirmation;
import fr.arpinum.cocoritest.interne.affirmation.objet.AffirmationObjetAuMasculinDeBase;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.affirmation.booleene;
public class AffirmationBooleeneDeBase extends Affirmation implements AffirmationBooleene,
AffirmationBooleeneAuFeminin {
public AffirmationBooleeneDeBase(Boolean valeur) {
booléen = valeur;
}
@Override
public void estVrai() {
affirmeQueLeBooléenEst(true);
}
@Override
public void estVraie() {
estVrai();
}
@Override
public void estFaux() {
affirmeQueLeBooléenEst(false);
}
@Override
public void estFausse() {
estFaux();
}
private void affirmeQueLeBooléenEst(boolean attendue) {
|
new AffirmationObjetAuMasculinDeBase<>(booléen).est(attendue);
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/affirmation/objet/AffirmationObjet.java
|
// Path: src/main/java/fr/arpinum/cocoritest/conjonction/Conjonction.java
// @FunctionalInterface
// public interface Conjonction<T> {
//
// T et();
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
|
import fr.arpinum.cocoritest.conjonction.Conjonction;
import fr.arpinum.cocoritest.specification.Specification;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.affirmation.objet;
/**
* Représente une affirmation concernant un objet typé.
*
* @param <TObjet> le type de l'objet concerné par l'affirmation.
* @param <TConjonction> le type de conjonction utilisé pour chaîner les affirmations.
*/
public interface AffirmationObjet<TObjet, TConjonction extends Conjonction<? extends AffirmationObjet<TObjet,
? extends TConjonction>>> {
/**
* Affirme que l'objet est celui attendu.
*
* @param objetAttendu l'objet attendu.
* @return une conjonction pour chaîner d'autres affirmations
* @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
*/
TConjonction est(TObjet objetAttendu);
/**
* Affirme que l'objet n'est pas celui attendu.
*
* @param objetNonAttendu l'objet non attendu.
* @return une conjonction pour chaîner d'autres affirmations
* @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
*/
TConjonction nEstPas(TObjet objetNonAttendu);
/**
* Affirme que l'objet respecte la spécification.
*
* @param spécification la spécification à respecter.
* @return une conjonction pour chaîner d'autres affirmations
* @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
*/
|
// Path: src/main/java/fr/arpinum/cocoritest/conjonction/Conjonction.java
// @FunctionalInterface
// public interface Conjonction<T> {
//
// T et();
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
// Path: src/main/java/fr/arpinum/cocoritest/affirmation/objet/AffirmationObjet.java
import fr.arpinum.cocoritest.conjonction.Conjonction;
import fr.arpinum.cocoritest.specification.Specification;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.affirmation.objet;
/**
* Représente une affirmation concernant un objet typé.
*
* @param <TObjet> le type de l'objet concerné par l'affirmation.
* @param <TConjonction> le type de conjonction utilisé pour chaîner les affirmations.
*/
public interface AffirmationObjet<TObjet, TConjonction extends Conjonction<? extends AffirmationObjet<TObjet,
? extends TConjonction>>> {
/**
* Affirme que l'objet est celui attendu.
*
* @param objetAttendu l'objet attendu.
* @return une conjonction pour chaîner d'autres affirmations
* @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
*/
TConjonction est(TObjet objetAttendu);
/**
* Affirme que l'objet n'est pas celui attendu.
*
* @param objetNonAttendu l'objet non attendu.
* @return une conjonction pour chaîner d'autres affirmations
* @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
*/
TConjonction nEstPas(TObjet objetNonAttendu);
/**
* Affirme que l'objet respecte la spécification.
*
* @param spécification la spécification à respecter.
* @return une conjonction pour chaîner d'autres affirmations
* @throws fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation si l'affirmation est erronée.
*/
|
TConjonction respecte(Specification<TObjet> spécification);
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/interne/specification/collection/SpecificationCollection.java
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Collections.java
// public class Collections {
//
// public static <T> boolean egales(Collection<T> gauche, Collection<T> droite) {
// if (gauche == null || droite == null) {
// return gauche == droite;
// }
// return mêmesTailles(gauche, droite) && lesCollectionsDeMêmeTailleSontEgales(gauche, droite);
// }
//
// private static <T> boolean mêmesTailles(Collection<T> gauche, Collection<T> droite) {
// return gauche.size() == droite.size();
// }
//
// private static <T> boolean lesCollectionsDeMêmeTailleSontEgales(Collection<T> gauche, Collection<T> droite) {
// Iterator<T> premierItérateur = gauche.iterator();
// Iterator<T> secondItérateur = droite.iterator();
// while (premierItérateur.hasNext()) {
// if (Objets.différents(premierItérateur.next(), secondItérateur.next())) {
// return false;
// }
// }
// return true;
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
|
import java.util.Collection;
import fr.arpinum.cocoritest.interne.extensionlangage.Collections;
import fr.arpinum.cocoritest.specification.Specification;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.specification.collection;
public class SpecificationCollection<E> implements Specification<Collection<E>> {
public SpecificationCollection(Collection<E> élémentsSpécifiés) {
this.collectionSpécifiée = élémentsSpécifiés;
}
@Override
public boolean estSatisfaitePar(Collection<E> éléments) {
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Collections.java
// public class Collections {
//
// public static <T> boolean egales(Collection<T> gauche, Collection<T> droite) {
// if (gauche == null || droite == null) {
// return gauche == droite;
// }
// return mêmesTailles(gauche, droite) && lesCollectionsDeMêmeTailleSontEgales(gauche, droite);
// }
//
// private static <T> boolean mêmesTailles(Collection<T> gauche, Collection<T> droite) {
// return gauche.size() == droite.size();
// }
//
// private static <T> boolean lesCollectionsDeMêmeTailleSontEgales(Collection<T> gauche, Collection<T> droite) {
// Iterator<T> premierItérateur = gauche.iterator();
// Iterator<T> secondItérateur = droite.iterator();
// while (premierItérateur.hasNext()) {
// if (Objets.différents(premierItérateur.next(), secondItérateur.next())) {
// return false;
// }
// }
// return true;
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/collection/SpecificationCollection.java
import java.util.Collection;
import fr.arpinum.cocoritest.interne.extensionlangage.Collections;
import fr.arpinum.cocoritest.specification.Specification;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.specification.collection;
public class SpecificationCollection<E> implements Specification<Collection<E>> {
public SpecificationCollection(Collection<E> élémentsSpécifiés) {
this.collectionSpécifiée = élémentsSpécifiés;
}
@Override
public boolean estSatisfaitePar(Collection<E> éléments) {
|
return Collections.egales(collectionSpécifiée, éléments);
|
arpinum-oss/cocoritest
|
src/test/java/fr/arpinum/cocoritest/FabriquePourTest.java
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/ExceptionAffirmation.java
// public class ExceptionAffirmation extends RuntimeException {
//
// public ExceptionAffirmation(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationAutreObjet.java
// public class SpecificationAutreObjet<T> implements Specification<T> {
//
// public SpecificationAutreObjet(T objetSpécifié) {
// this.objetSpécifié = objetSpécifié;
// }
//
// @Override
// public boolean estSatisfaitePar(T objet) {
// return !Objets.egaux(objetSpécifié, objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// return String.format("L'objet est <%s> alors que ce n'était pas voulu.", Objets.enChaîne(objet));
// }
//
// private final T objetSpécifié;
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
|
import fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.objet.SpecificationAutreObjet;
import fr.arpinum.cocoritest.specification.Specification;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
public class FabriquePourTest {
private FabriquePourTest() {
}
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/ExceptionAffirmation.java
// public class ExceptionAffirmation extends RuntimeException {
//
// public ExceptionAffirmation(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationAutreObjet.java
// public class SpecificationAutreObjet<T> implements Specification<T> {
//
// public SpecificationAutreObjet(T objetSpécifié) {
// this.objetSpécifié = objetSpécifié;
// }
//
// @Override
// public boolean estSatisfaitePar(T objet) {
// return !Objets.egaux(objetSpécifié, objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// return String.format("L'objet est <%s> alors que ce n'était pas voulu.", Objets.enChaîne(objet));
// }
//
// private final T objetSpécifié;
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
// Path: src/test/java/fr/arpinum/cocoritest/FabriquePourTest.java
import fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.objet.SpecificationAutreObjet;
import fr.arpinum.cocoritest.specification.Specification;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
public class FabriquePourTest {
private FabriquePourTest() {
}
|
public static Specification<Exception> créeSpécificationException(String messageAttendu) {
|
arpinum-oss/cocoritest
|
src/test/java/fr/arpinum/cocoritest/FabriquePourTest.java
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/ExceptionAffirmation.java
// public class ExceptionAffirmation extends RuntimeException {
//
// public ExceptionAffirmation(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationAutreObjet.java
// public class SpecificationAutreObjet<T> implements Specification<T> {
//
// public SpecificationAutreObjet(T objetSpécifié) {
// this.objetSpécifié = objetSpécifié;
// }
//
// @Override
// public boolean estSatisfaitePar(T objet) {
// return !Objets.egaux(objetSpécifié, objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// return String.format("L'objet est <%s> alors que ce n'était pas voulu.", Objets.enChaîne(objet));
// }
//
// private final T objetSpécifié;
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
|
import fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.objet.SpecificationAutreObjet;
import fr.arpinum.cocoritest.specification.Specification;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
public class FabriquePourTest {
private FabriquePourTest() {
}
public static Specification<Exception> créeSpécificationException(String messageAttendu) {
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/ExceptionAffirmation.java
// public class ExceptionAffirmation extends RuntimeException {
//
// public ExceptionAffirmation(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationAutreObjet.java
// public class SpecificationAutreObjet<T> implements Specification<T> {
//
// public SpecificationAutreObjet(T objetSpécifié) {
// this.objetSpécifié = objetSpécifié;
// }
//
// @Override
// public boolean estSatisfaitePar(T objet) {
// return !Objets.egaux(objetSpécifié, objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// return String.format("L'objet est <%s> alors que ce n'était pas voulu.", Objets.enChaîne(objet));
// }
//
// private final T objetSpécifié;
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
// Path: src/test/java/fr/arpinum/cocoritest/FabriquePourTest.java
import fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.objet.SpecificationAutreObjet;
import fr.arpinum.cocoritest.specification.Specification;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
public class FabriquePourTest {
private FabriquePourTest() {
}
public static Specification<Exception> créeSpécificationException(String messageAttendu) {
|
return new SpecificationAutreObjet<>((Exception) null)
|
arpinum-oss/cocoritest
|
src/test/java/fr/arpinum/cocoritest/FabriquePourTest.java
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/ExceptionAffirmation.java
// public class ExceptionAffirmation extends RuntimeException {
//
// public ExceptionAffirmation(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationAutreObjet.java
// public class SpecificationAutreObjet<T> implements Specification<T> {
//
// public SpecificationAutreObjet(T objetSpécifié) {
// this.objetSpécifié = objetSpécifié;
// }
//
// @Override
// public boolean estSatisfaitePar(T objet) {
// return !Objets.egaux(objetSpécifié, objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// return String.format("L'objet est <%s> alors que ce n'était pas voulu.", Objets.enChaîne(objet));
// }
//
// private final T objetSpécifié;
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
|
import fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.objet.SpecificationAutreObjet;
import fr.arpinum.cocoritest.specification.Specification;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
public class FabriquePourTest {
private FabriquePourTest() {
}
public static Specification<Exception> créeSpécificationException(String messageAttendu) {
return new SpecificationAutreObjet<>((Exception) null)
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/ExceptionAffirmation.java
// public class ExceptionAffirmation extends RuntimeException {
//
// public ExceptionAffirmation(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationAutreObjet.java
// public class SpecificationAutreObjet<T> implements Specification<T> {
//
// public SpecificationAutreObjet(T objetSpécifié) {
// this.objetSpécifié = objetSpécifié;
// }
//
// @Override
// public boolean estSatisfaitePar(T objet) {
// return !Objets.egaux(objetSpécifié, objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// return String.format("L'objet est <%s> alors que ce n'était pas voulu.", Objets.enChaîne(objet));
// }
//
// private final T objetSpécifié;
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
// Path: src/test/java/fr/arpinum/cocoritest/FabriquePourTest.java
import fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.objet.SpecificationAutreObjet;
import fr.arpinum.cocoritest.specification.Specification;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
public class FabriquePourTest {
private FabriquePourTest() {
}
public static Specification<Exception> créeSpécificationException(String messageAttendu) {
return new SpecificationAutreObjet<>((Exception) null)
|
.et(créeSpécificationObjetDeType(ExceptionAffirmation.class))
|
arpinum-oss/cocoritest
|
src/test/java/fr/arpinum/cocoritest/FabriquePourTest.java
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/ExceptionAffirmation.java
// public class ExceptionAffirmation extends RuntimeException {
//
// public ExceptionAffirmation(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationAutreObjet.java
// public class SpecificationAutreObjet<T> implements Specification<T> {
//
// public SpecificationAutreObjet(T objetSpécifié) {
// this.objetSpécifié = objetSpécifié;
// }
//
// @Override
// public boolean estSatisfaitePar(T objet) {
// return !Objets.egaux(objetSpécifié, objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// return String.format("L'objet est <%s> alors que ce n'était pas voulu.", Objets.enChaîne(objet));
// }
//
// private final T objetSpécifié;
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
|
import fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.objet.SpecificationAutreObjet;
import fr.arpinum.cocoritest.specification.Specification;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
public class FabriquePourTest {
private FabriquePourTest() {
}
public static Specification<Exception> créeSpécificationException(String messageAttendu) {
return new SpecificationAutreObjet<>((Exception) null)
.et(créeSpécificationObjetDeType(ExceptionAffirmation.class))
.et(créeSpécificationMessageException(messageAttendu));
}
private static Specification<Exception> créeSpécificationMessageException(final String messageAttendu) {
return new Specification<Exception>() {
@Override
public boolean estSatisfaitePar(Exception objet) {
|
// Path: src/main/java/fr/arpinum/cocoritest/interne/affirmation/ExceptionAffirmation.java
// public class ExceptionAffirmation extends RuntimeException {
//
// public ExceptionAffirmation(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/extensionlangage/Objets.java
// public class Objets {
//
// public static boolean egaux(Object gauche, Object droite) {
// if (gauche == null) {
// return droite == null;
// }
// return gauche.equals(droite);
// }
//
// public static boolean différents(Object gauche, Object droite) {
// return !egaux(gauche, droite);
// }
//
// public static String enChaîne(Object objet) {
// if (objet == null) {
// return "nul";
// }
// if (objet instanceof Boolean) {
// return ((Boolean) objet) ? "vrai" : "faux";
// }
// return objet.toString();
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/specification/objet/SpecificationAutreObjet.java
// public class SpecificationAutreObjet<T> implements Specification<T> {
//
// public SpecificationAutreObjet(T objetSpécifié) {
// this.objetSpécifié = objetSpécifié;
// }
//
// @Override
// public boolean estSatisfaitePar(T objet) {
// return !Objets.egaux(objetSpécifié, objet);
// }
//
// @Override
// public String messageInsatisfactionPour(T objet) {
// return String.format("L'objet est <%s> alors que ce n'était pas voulu.", Objets.enChaîne(objet));
// }
//
// private final T objetSpécifié;
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/specification/Specification.java
// @FunctionalInterface
// public interface Specification<T> {
//
// /**
// * Informe si la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet sur lequel est vérifiée l'insatisfaction de la spécification.
// * @return true si la spécification n'est pas satisfaite par l'objet, faux sinon.
// */
// boolean estSatisfaitePar(T objet);
//
// /**
// * Le message décrivant pourquoi la spécification n'est pas satisfaite par l'objet.
// *
// * @param objet l'objet qui ne satisfait pas la spécification.
// * @return le message décrivant pourquoi la spécification n'est pas satisfaite.
// */
// default String messageInsatisfactionPour(T objet) {
// return Objets.enChaîne(objet) + " ne respecte pas la spécification.";
// }
//
// /**
// * Combine la spécification avec une autre. La spécification combinée est satisfaite si les deux spécifications de
// * la combinaison le sont pour l'objet.
// * Le message d'insatisfaction est celui de la première spécification de la combinaison qui n'est pas satisfaite.
// *
// * @param autreSpécification l'autre spécification à combiner.
// * @return la spécification combinée.
// */
// default Specification<T> et(Specification<? super T> autreSpécification) {
// Objects.requireNonNull(autreSpécification, "L'autre spécification ne doit pas être nulle.");
// return new FabriqueSpecification().combine(this, autreSpécification);
// }
// }
// Path: src/test/java/fr/arpinum/cocoritest/FabriquePourTest.java
import fr.arpinum.cocoritest.interne.affirmation.ExceptionAffirmation;
import fr.arpinum.cocoritest.interne.extensionlangage.Objets;
import fr.arpinum.cocoritest.interne.specification.objet.SpecificationAutreObjet;
import fr.arpinum.cocoritest.specification.Specification;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
public class FabriquePourTest {
private FabriquePourTest() {
}
public static Specification<Exception> créeSpécificationException(String messageAttendu) {
return new SpecificationAutreObjet<>((Exception) null)
.et(créeSpécificationObjetDeType(ExceptionAffirmation.class))
.et(créeSpécificationMessageException(messageAttendu));
}
private static Specification<Exception> créeSpécificationMessageException(final String messageAttendu) {
return new Specification<Exception>() {
@Override
public boolean estSatisfaitePar(Exception objet) {
|
return !Objets.différents(objet.getMessage(), messageAttendu);
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/Outils.java
|
// Path: src/main/java/fr/arpinum/cocoritest/exception/CapteurException.java
// public interface CapteurException {
//
// /**
// * Capture une éventuelle exception dans l'action et la retourne.
// *
// * @param action l'action succeptible de lever une exception.
// * @return l'exception capturée ou null si aucune exception.
// */
// Exception capte(Action action);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/injection/Injecteur.java
// public interface Injecteur {
//
// /**
// * Injecte des dépendances à un objet.
// *
// * @param dépendances les dépendances à injecter.
// * @return l'injecteur pour pouvoir chaîner les injections.
// */
// Injecteur injecte(Object... dépendances);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/exception/CapteurExceptionDeBase.java
// public class CapteurExceptionDeBase implements CapteurException {
//
// @Override
// public Exception capte(Action action) {
// try {
// action.exécute();
// } catch (Exception e) {
// return e;
// }
// return null;
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/injection/InjecteurDeBase.java
// public class InjecteurDeBase implements Injecteur {
//
// public InjecteurDeBase(Object objet) {
// this.objet = objet;
// }
//
// @Override
// public Injecteur injecte(Object... dépendances) {
// Listes.cree(dépendances).forEach(this::injecte);
// return this;
// }
//
// private void injecte(Object dépendance) {
// List<Field> champsAssignables = récupèreChampsAssignables(dépendance);
// if (champsAssignables.size() == 0) {
// throw new IllegalArgumentException(String.format("Impossible d'assigner la dépendance %s",
// dépendance));
// }
// assigneLesChampsAssignables(dépendance, champsAssignables);
// }
//
// private void assigneLesChampsAssignables(Object dépendance, List<Field> champsAssignables) {
// champsAssignables.forEach((champ) -> forceLAssignation(dépendance, champ));
// }
//
// private void forceLAssignation(Object dépendance, Field champ) {
// champ.setAccessible(true);
// assigne(dépendance, champ);
// }
//
// private void assigne(Object dépendance, Field champ) {
// try {
// champ.set(objet, dépendance);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private List<Field> récupèreChampsAssignables(Object dépendance) {
// return récupèreTousLesChamps().stream().filter(champAssignableDepuis(dépendance)).collect(Collectors.toList());
// }
//
// private Predicate<Field> champAssignableDepuis(Object dépendance) {
// return (champ) -> champ.getType().isAssignableFrom(dépendance.getClass());
// }
//
// private List<Field> récupèreTousLesChamps() {
// return récupèreTousLesChampsPour(objet.getClass());
// }
//
// private List<Field> récupèreTousLesChampsPour(Class<?> classe) {
// List<Field> résultat = récupèreTousLesChampsDéclarés(classe);
// if (classe.getSuperclass() != null) {
// résultat.addAll(récupèreTousLesChampsPour(classe.getSuperclass()));
// }
// return résultat;
// }
//
// private List<Field> récupèreTousLesChampsDéclarés(Class<?> classe) {
// return Listes.cree(classe.getDeclaredFields());
// }
//
// private final Object objet;
// }
|
import fr.arpinum.cocoritest.exception.CapteurException;
import fr.arpinum.cocoritest.injection.Injecteur;
import fr.arpinum.cocoritest.interne.exception.CapteurExceptionDeBase;
import fr.arpinum.cocoritest.interne.injection.InjecteurDeBase;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
/**
* Fabrique qui permet de construire les différents outils.
*/
public class Outils {
/**
* Crée une nouvelle instance d'un capteur d'exception.
*
* @return le capteur créé.
*/
public static CapteurException créeCapteur() {
|
// Path: src/main/java/fr/arpinum/cocoritest/exception/CapteurException.java
// public interface CapteurException {
//
// /**
// * Capture une éventuelle exception dans l'action et la retourne.
// *
// * @param action l'action succeptible de lever une exception.
// * @return l'exception capturée ou null si aucune exception.
// */
// Exception capte(Action action);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/injection/Injecteur.java
// public interface Injecteur {
//
// /**
// * Injecte des dépendances à un objet.
// *
// * @param dépendances les dépendances à injecter.
// * @return l'injecteur pour pouvoir chaîner les injections.
// */
// Injecteur injecte(Object... dépendances);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/exception/CapteurExceptionDeBase.java
// public class CapteurExceptionDeBase implements CapteurException {
//
// @Override
// public Exception capte(Action action) {
// try {
// action.exécute();
// } catch (Exception e) {
// return e;
// }
// return null;
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/injection/InjecteurDeBase.java
// public class InjecteurDeBase implements Injecteur {
//
// public InjecteurDeBase(Object objet) {
// this.objet = objet;
// }
//
// @Override
// public Injecteur injecte(Object... dépendances) {
// Listes.cree(dépendances).forEach(this::injecte);
// return this;
// }
//
// private void injecte(Object dépendance) {
// List<Field> champsAssignables = récupèreChampsAssignables(dépendance);
// if (champsAssignables.size() == 0) {
// throw new IllegalArgumentException(String.format("Impossible d'assigner la dépendance %s",
// dépendance));
// }
// assigneLesChampsAssignables(dépendance, champsAssignables);
// }
//
// private void assigneLesChampsAssignables(Object dépendance, List<Field> champsAssignables) {
// champsAssignables.forEach((champ) -> forceLAssignation(dépendance, champ));
// }
//
// private void forceLAssignation(Object dépendance, Field champ) {
// champ.setAccessible(true);
// assigne(dépendance, champ);
// }
//
// private void assigne(Object dépendance, Field champ) {
// try {
// champ.set(objet, dépendance);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private List<Field> récupèreChampsAssignables(Object dépendance) {
// return récupèreTousLesChamps().stream().filter(champAssignableDepuis(dépendance)).collect(Collectors.toList());
// }
//
// private Predicate<Field> champAssignableDepuis(Object dépendance) {
// return (champ) -> champ.getType().isAssignableFrom(dépendance.getClass());
// }
//
// private List<Field> récupèreTousLesChamps() {
// return récupèreTousLesChampsPour(objet.getClass());
// }
//
// private List<Field> récupèreTousLesChampsPour(Class<?> classe) {
// List<Field> résultat = récupèreTousLesChampsDéclarés(classe);
// if (classe.getSuperclass() != null) {
// résultat.addAll(récupèreTousLesChampsPour(classe.getSuperclass()));
// }
// return résultat;
// }
//
// private List<Field> récupèreTousLesChampsDéclarés(Class<?> classe) {
// return Listes.cree(classe.getDeclaredFields());
// }
//
// private final Object objet;
// }
// Path: src/main/java/fr/arpinum/cocoritest/Outils.java
import fr.arpinum.cocoritest.exception.CapteurException;
import fr.arpinum.cocoritest.injection.Injecteur;
import fr.arpinum.cocoritest.interne.exception.CapteurExceptionDeBase;
import fr.arpinum.cocoritest.interne.injection.InjecteurDeBase;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
/**
* Fabrique qui permet de construire les différents outils.
*/
public class Outils {
/**
* Crée une nouvelle instance d'un capteur d'exception.
*
* @return le capteur créé.
*/
public static CapteurException créeCapteur() {
|
return new CapteurExceptionDeBase();
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/Outils.java
|
// Path: src/main/java/fr/arpinum/cocoritest/exception/CapteurException.java
// public interface CapteurException {
//
// /**
// * Capture une éventuelle exception dans l'action et la retourne.
// *
// * @param action l'action succeptible de lever une exception.
// * @return l'exception capturée ou null si aucune exception.
// */
// Exception capte(Action action);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/injection/Injecteur.java
// public interface Injecteur {
//
// /**
// * Injecte des dépendances à un objet.
// *
// * @param dépendances les dépendances à injecter.
// * @return l'injecteur pour pouvoir chaîner les injections.
// */
// Injecteur injecte(Object... dépendances);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/exception/CapteurExceptionDeBase.java
// public class CapteurExceptionDeBase implements CapteurException {
//
// @Override
// public Exception capte(Action action) {
// try {
// action.exécute();
// } catch (Exception e) {
// return e;
// }
// return null;
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/injection/InjecteurDeBase.java
// public class InjecteurDeBase implements Injecteur {
//
// public InjecteurDeBase(Object objet) {
// this.objet = objet;
// }
//
// @Override
// public Injecteur injecte(Object... dépendances) {
// Listes.cree(dépendances).forEach(this::injecte);
// return this;
// }
//
// private void injecte(Object dépendance) {
// List<Field> champsAssignables = récupèreChampsAssignables(dépendance);
// if (champsAssignables.size() == 0) {
// throw new IllegalArgumentException(String.format("Impossible d'assigner la dépendance %s",
// dépendance));
// }
// assigneLesChampsAssignables(dépendance, champsAssignables);
// }
//
// private void assigneLesChampsAssignables(Object dépendance, List<Field> champsAssignables) {
// champsAssignables.forEach((champ) -> forceLAssignation(dépendance, champ));
// }
//
// private void forceLAssignation(Object dépendance, Field champ) {
// champ.setAccessible(true);
// assigne(dépendance, champ);
// }
//
// private void assigne(Object dépendance, Field champ) {
// try {
// champ.set(objet, dépendance);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private List<Field> récupèreChampsAssignables(Object dépendance) {
// return récupèreTousLesChamps().stream().filter(champAssignableDepuis(dépendance)).collect(Collectors.toList());
// }
//
// private Predicate<Field> champAssignableDepuis(Object dépendance) {
// return (champ) -> champ.getType().isAssignableFrom(dépendance.getClass());
// }
//
// private List<Field> récupèreTousLesChamps() {
// return récupèreTousLesChampsPour(objet.getClass());
// }
//
// private List<Field> récupèreTousLesChampsPour(Class<?> classe) {
// List<Field> résultat = récupèreTousLesChampsDéclarés(classe);
// if (classe.getSuperclass() != null) {
// résultat.addAll(récupèreTousLesChampsPour(classe.getSuperclass()));
// }
// return résultat;
// }
//
// private List<Field> récupèreTousLesChampsDéclarés(Class<?> classe) {
// return Listes.cree(classe.getDeclaredFields());
// }
//
// private final Object objet;
// }
|
import fr.arpinum.cocoritest.exception.CapteurException;
import fr.arpinum.cocoritest.injection.Injecteur;
import fr.arpinum.cocoritest.interne.exception.CapteurExceptionDeBase;
import fr.arpinum.cocoritest.interne.injection.InjecteurDeBase;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
/**
* Fabrique qui permet de construire les différents outils.
*/
public class Outils {
/**
* Crée une nouvelle instance d'un capteur d'exception.
*
* @return le capteur créé.
*/
public static CapteurException créeCapteur() {
return new CapteurExceptionDeBase();
}
/**
* Crée une nouvelle instance de l'injecteur de dépendance.
*
* @param objet la cible de l'injection.
* @return l'injecteur créé.
*/
|
// Path: src/main/java/fr/arpinum/cocoritest/exception/CapteurException.java
// public interface CapteurException {
//
// /**
// * Capture une éventuelle exception dans l'action et la retourne.
// *
// * @param action l'action succeptible de lever une exception.
// * @return l'exception capturée ou null si aucune exception.
// */
// Exception capte(Action action);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/injection/Injecteur.java
// public interface Injecteur {
//
// /**
// * Injecte des dépendances à un objet.
// *
// * @param dépendances les dépendances à injecter.
// * @return l'injecteur pour pouvoir chaîner les injections.
// */
// Injecteur injecte(Object... dépendances);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/exception/CapteurExceptionDeBase.java
// public class CapteurExceptionDeBase implements CapteurException {
//
// @Override
// public Exception capte(Action action) {
// try {
// action.exécute();
// } catch (Exception e) {
// return e;
// }
// return null;
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/injection/InjecteurDeBase.java
// public class InjecteurDeBase implements Injecteur {
//
// public InjecteurDeBase(Object objet) {
// this.objet = objet;
// }
//
// @Override
// public Injecteur injecte(Object... dépendances) {
// Listes.cree(dépendances).forEach(this::injecte);
// return this;
// }
//
// private void injecte(Object dépendance) {
// List<Field> champsAssignables = récupèreChampsAssignables(dépendance);
// if (champsAssignables.size() == 0) {
// throw new IllegalArgumentException(String.format("Impossible d'assigner la dépendance %s",
// dépendance));
// }
// assigneLesChampsAssignables(dépendance, champsAssignables);
// }
//
// private void assigneLesChampsAssignables(Object dépendance, List<Field> champsAssignables) {
// champsAssignables.forEach((champ) -> forceLAssignation(dépendance, champ));
// }
//
// private void forceLAssignation(Object dépendance, Field champ) {
// champ.setAccessible(true);
// assigne(dépendance, champ);
// }
//
// private void assigne(Object dépendance, Field champ) {
// try {
// champ.set(objet, dépendance);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private List<Field> récupèreChampsAssignables(Object dépendance) {
// return récupèreTousLesChamps().stream().filter(champAssignableDepuis(dépendance)).collect(Collectors.toList());
// }
//
// private Predicate<Field> champAssignableDepuis(Object dépendance) {
// return (champ) -> champ.getType().isAssignableFrom(dépendance.getClass());
// }
//
// private List<Field> récupèreTousLesChamps() {
// return récupèreTousLesChampsPour(objet.getClass());
// }
//
// private List<Field> récupèreTousLesChampsPour(Class<?> classe) {
// List<Field> résultat = récupèreTousLesChampsDéclarés(classe);
// if (classe.getSuperclass() != null) {
// résultat.addAll(récupèreTousLesChampsPour(classe.getSuperclass()));
// }
// return résultat;
// }
//
// private List<Field> récupèreTousLesChampsDéclarés(Class<?> classe) {
// return Listes.cree(classe.getDeclaredFields());
// }
//
// private final Object objet;
// }
// Path: src/main/java/fr/arpinum/cocoritest/Outils.java
import fr.arpinum.cocoritest.exception.CapteurException;
import fr.arpinum.cocoritest.injection.Injecteur;
import fr.arpinum.cocoritest.interne.exception.CapteurExceptionDeBase;
import fr.arpinum.cocoritest.interne.injection.InjecteurDeBase;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
/**
* Fabrique qui permet de construire les différents outils.
*/
public class Outils {
/**
* Crée une nouvelle instance d'un capteur d'exception.
*
* @return le capteur créé.
*/
public static CapteurException créeCapteur() {
return new CapteurExceptionDeBase();
}
/**
* Crée une nouvelle instance de l'injecteur de dépendance.
*
* @param objet la cible de l'injection.
* @return l'injecteur créé.
*/
|
public static Injecteur créeInjecteur(Object objet) {
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/Outils.java
|
// Path: src/main/java/fr/arpinum/cocoritest/exception/CapteurException.java
// public interface CapteurException {
//
// /**
// * Capture une éventuelle exception dans l'action et la retourne.
// *
// * @param action l'action succeptible de lever une exception.
// * @return l'exception capturée ou null si aucune exception.
// */
// Exception capte(Action action);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/injection/Injecteur.java
// public interface Injecteur {
//
// /**
// * Injecte des dépendances à un objet.
// *
// * @param dépendances les dépendances à injecter.
// * @return l'injecteur pour pouvoir chaîner les injections.
// */
// Injecteur injecte(Object... dépendances);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/exception/CapteurExceptionDeBase.java
// public class CapteurExceptionDeBase implements CapteurException {
//
// @Override
// public Exception capte(Action action) {
// try {
// action.exécute();
// } catch (Exception e) {
// return e;
// }
// return null;
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/injection/InjecteurDeBase.java
// public class InjecteurDeBase implements Injecteur {
//
// public InjecteurDeBase(Object objet) {
// this.objet = objet;
// }
//
// @Override
// public Injecteur injecte(Object... dépendances) {
// Listes.cree(dépendances).forEach(this::injecte);
// return this;
// }
//
// private void injecte(Object dépendance) {
// List<Field> champsAssignables = récupèreChampsAssignables(dépendance);
// if (champsAssignables.size() == 0) {
// throw new IllegalArgumentException(String.format("Impossible d'assigner la dépendance %s",
// dépendance));
// }
// assigneLesChampsAssignables(dépendance, champsAssignables);
// }
//
// private void assigneLesChampsAssignables(Object dépendance, List<Field> champsAssignables) {
// champsAssignables.forEach((champ) -> forceLAssignation(dépendance, champ));
// }
//
// private void forceLAssignation(Object dépendance, Field champ) {
// champ.setAccessible(true);
// assigne(dépendance, champ);
// }
//
// private void assigne(Object dépendance, Field champ) {
// try {
// champ.set(objet, dépendance);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private List<Field> récupèreChampsAssignables(Object dépendance) {
// return récupèreTousLesChamps().stream().filter(champAssignableDepuis(dépendance)).collect(Collectors.toList());
// }
//
// private Predicate<Field> champAssignableDepuis(Object dépendance) {
// return (champ) -> champ.getType().isAssignableFrom(dépendance.getClass());
// }
//
// private List<Field> récupèreTousLesChamps() {
// return récupèreTousLesChampsPour(objet.getClass());
// }
//
// private List<Field> récupèreTousLesChampsPour(Class<?> classe) {
// List<Field> résultat = récupèreTousLesChampsDéclarés(classe);
// if (classe.getSuperclass() != null) {
// résultat.addAll(récupèreTousLesChampsPour(classe.getSuperclass()));
// }
// return résultat;
// }
//
// private List<Field> récupèreTousLesChampsDéclarés(Class<?> classe) {
// return Listes.cree(classe.getDeclaredFields());
// }
//
// private final Object objet;
// }
|
import fr.arpinum.cocoritest.exception.CapteurException;
import fr.arpinum.cocoritest.injection.Injecteur;
import fr.arpinum.cocoritest.interne.exception.CapteurExceptionDeBase;
import fr.arpinum.cocoritest.interne.injection.InjecteurDeBase;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
/**
* Fabrique qui permet de construire les différents outils.
*/
public class Outils {
/**
* Crée une nouvelle instance d'un capteur d'exception.
*
* @return le capteur créé.
*/
public static CapteurException créeCapteur() {
return new CapteurExceptionDeBase();
}
/**
* Crée une nouvelle instance de l'injecteur de dépendance.
*
* @param objet la cible de l'injection.
* @return l'injecteur créé.
*/
public static Injecteur créeInjecteur(Object objet) {
|
// Path: src/main/java/fr/arpinum/cocoritest/exception/CapteurException.java
// public interface CapteurException {
//
// /**
// * Capture une éventuelle exception dans l'action et la retourne.
// *
// * @param action l'action succeptible de lever une exception.
// * @return l'exception capturée ou null si aucune exception.
// */
// Exception capte(Action action);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/injection/Injecteur.java
// public interface Injecteur {
//
// /**
// * Injecte des dépendances à un objet.
// *
// * @param dépendances les dépendances à injecter.
// * @return l'injecteur pour pouvoir chaîner les injections.
// */
// Injecteur injecte(Object... dépendances);
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/exception/CapteurExceptionDeBase.java
// public class CapteurExceptionDeBase implements CapteurException {
//
// @Override
// public Exception capte(Action action) {
// try {
// action.exécute();
// } catch (Exception e) {
// return e;
// }
// return null;
// }
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/interne/injection/InjecteurDeBase.java
// public class InjecteurDeBase implements Injecteur {
//
// public InjecteurDeBase(Object objet) {
// this.objet = objet;
// }
//
// @Override
// public Injecteur injecte(Object... dépendances) {
// Listes.cree(dépendances).forEach(this::injecte);
// return this;
// }
//
// private void injecte(Object dépendance) {
// List<Field> champsAssignables = récupèreChampsAssignables(dépendance);
// if (champsAssignables.size() == 0) {
// throw new IllegalArgumentException(String.format("Impossible d'assigner la dépendance %s",
// dépendance));
// }
// assigneLesChampsAssignables(dépendance, champsAssignables);
// }
//
// private void assigneLesChampsAssignables(Object dépendance, List<Field> champsAssignables) {
// champsAssignables.forEach((champ) -> forceLAssignation(dépendance, champ));
// }
//
// private void forceLAssignation(Object dépendance, Field champ) {
// champ.setAccessible(true);
// assigne(dépendance, champ);
// }
//
// private void assigne(Object dépendance, Field champ) {
// try {
// champ.set(objet, dépendance);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private List<Field> récupèreChampsAssignables(Object dépendance) {
// return récupèreTousLesChamps().stream().filter(champAssignableDepuis(dépendance)).collect(Collectors.toList());
// }
//
// private Predicate<Field> champAssignableDepuis(Object dépendance) {
// return (champ) -> champ.getType().isAssignableFrom(dépendance.getClass());
// }
//
// private List<Field> récupèreTousLesChamps() {
// return récupèreTousLesChampsPour(objet.getClass());
// }
//
// private List<Field> récupèreTousLesChampsPour(Class<?> classe) {
// List<Field> résultat = récupèreTousLesChampsDéclarés(classe);
// if (classe.getSuperclass() != null) {
// résultat.addAll(récupèreTousLesChampsPour(classe.getSuperclass()));
// }
// return résultat;
// }
//
// private List<Field> récupèreTousLesChampsDéclarés(Class<?> classe) {
// return Listes.cree(classe.getDeclaredFields());
// }
//
// private final Object objet;
// }
// Path: src/main/java/fr/arpinum/cocoritest/Outils.java
import fr.arpinum.cocoritest.exception.CapteurException;
import fr.arpinum.cocoritest.injection.Injecteur;
import fr.arpinum.cocoritest.interne.exception.CapteurExceptionDeBase;
import fr.arpinum.cocoritest.interne.injection.InjecteurDeBase;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest;
/**
* Fabrique qui permet de construire les différents outils.
*/
public class Outils {
/**
* Crée une nouvelle instance d'un capteur d'exception.
*
* @return le capteur créé.
*/
public static CapteurException créeCapteur() {
return new CapteurExceptionDeBase();
}
/**
* Crée une nouvelle instance de l'injecteur de dépendance.
*
* @param objet la cible de l'injection.
* @return l'injecteur créé.
*/
public static Injecteur créeInjecteur(Object objet) {
|
return new InjecteurDeBase(objet);
|
arpinum-oss/cocoritest
|
src/main/java/fr/arpinum/cocoritest/interne/exception/CapteurExceptionDeBase.java
|
// Path: src/main/java/fr/arpinum/cocoritest/exception/Action.java
// @FunctionalInterface
// public interface Action {
//
// /**
// * Exécute l'action. Permet aux implémentations d'héberger l'ensemble des instructions à exécuter.
// */
// void exécute();
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/exception/CapteurException.java
// public interface CapteurException {
//
// /**
// * Capture une éventuelle exception dans l'action et la retourne.
// *
// * @param action l'action succeptible de lever une exception.
// * @return l'exception capturée ou null si aucune exception.
// */
// Exception capte(Action action);
// }
|
import fr.arpinum.cocoritest.exception.Action;
import fr.arpinum.cocoritest.exception.CapteurException;
|
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.exception;
public class CapteurExceptionDeBase implements CapteurException {
@Override
|
// Path: src/main/java/fr/arpinum/cocoritest/exception/Action.java
// @FunctionalInterface
// public interface Action {
//
// /**
// * Exécute l'action. Permet aux implémentations d'héberger l'ensemble des instructions à exécuter.
// */
// void exécute();
// }
//
// Path: src/main/java/fr/arpinum/cocoritest/exception/CapteurException.java
// public interface CapteurException {
//
// /**
// * Capture une éventuelle exception dans l'action et la retourne.
// *
// * @param action l'action succeptible de lever une exception.
// * @return l'exception capturée ou null si aucune exception.
// */
// Exception capte(Action action);
// }
// Path: src/main/java/fr/arpinum/cocoritest/interne/exception/CapteurExceptionDeBase.java
import fr.arpinum.cocoritest.exception.Action;
import fr.arpinum.cocoritest.exception.CapteurException;
/*
* Copyright (C) 2013, Arpinum
*
* Cocoritest est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU Lesser
* General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence,
* soit (à votre gré) toute version ultérieure.
*
* Cocoritest est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; pas même la garantie
* implicite de COMMERCIABILISABILITÉ ni d'ADÉQUATION à UN OBJECTIF PARTICULIER. Consultez la GNU Lesser General
* Public License pour plus de détails.
*
* Vous devez avoir reçu une copie de la GNU Lesser General Public License en même temps que Cocoritest ; si ce n'est
* pas le cas, consultez http://www.gnu.org/licenses.
*/
package fr.arpinum.cocoritest.interne.exception;
public class CapteurExceptionDeBase implements CapteurException {
@Override
|
public Exception capte(Action action) {
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/trading/field/IEXPriceType.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.api.message.trading.field;
public enum IEXPriceType implements IEXByteEnum {
IEX_OFFICIAL_OPENING_PRICE((byte) 0x51),
IEX_OFFICIAL_CLOSING_PRICE((byte) 0x4d);
private static final Map<Byte, IEXPriceType> LOOKUP = new HashMap<>();
static {
for (final IEXPriceType value : EnumSet.allOf(IEXPriceType.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXPriceType(final byte code) {
this.code = code;
}
@Override
public byte getCode() {
return code;
}
public static IEXPriceType getPriceType(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/trading/field/IEXPriceType.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.api.message.trading.field;
public enum IEXPriceType implements IEXByteEnum {
IEX_OFFICIAL_OPENING_PRICE((byte) 0x51),
IEX_OFFICIAL_CLOSING_PRICE((byte) 0x4d);
private static final Map<Byte, IEXPriceType> LOOKUP = new HashMap<>();
static {
for (final IEXPriceType value : EnumSet.allOf(IEXPriceType.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXPriceType(final byte code) {
this.code = code;
}
@Override
public byte getCode() {
return code;
}
public static IEXPriceType getPriceType(final byte code) {
|
return lookup(IEXPriceType.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/IEXSegmentTest.java
|
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/builder/IEXMessageHeaderDataBuilder.java
// public static IEXMessageHeader defaultMessageHeader() {
// return messageHeader().build();
// }
//
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/trading/builder/IEXTradeMessageDataBuilder.java
// public static IEXTradeMessage defaultTradeMessage() {
// return tradeMessage().build();
// }
|
import org.junit.jupiter.api.Test;
import java.util.List;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static pl.zankowski.iextrading4j.hist.api.message.builder.IEXMessageHeaderDataBuilder.defaultMessageHeader;
import static pl.zankowski.iextrading4j.hist.api.message.trading.builder.IEXTradeMessageDataBuilder.defaultTradeMessage;
|
package pl.zankowski.iextrading4j.hist.api.message;
class IEXSegmentTest {
@Test
void shouldSuccessfullyCreateSegmentInstance() {
|
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/builder/IEXMessageHeaderDataBuilder.java
// public static IEXMessageHeader defaultMessageHeader() {
// return messageHeader().build();
// }
//
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/trading/builder/IEXTradeMessageDataBuilder.java
// public static IEXTradeMessage defaultTradeMessage() {
// return tradeMessage().build();
// }
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/IEXSegmentTest.java
import org.junit.jupiter.api.Test;
import java.util.List;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static pl.zankowski.iextrading4j.hist.api.message.builder.IEXMessageHeaderDataBuilder.defaultMessageHeader;
import static pl.zankowski.iextrading4j.hist.api.message.trading.builder.IEXTradeMessageDataBuilder.defaultTradeMessage;
package pl.zankowski.iextrading4j.hist.api.message;
class IEXSegmentTest {
@Test
void shouldSuccessfullyCreateSegmentInstance() {
|
final IEXMessageHeader iexMessageHeader = defaultMessageHeader();
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/IEXSegmentTest.java
|
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/builder/IEXMessageHeaderDataBuilder.java
// public static IEXMessageHeader defaultMessageHeader() {
// return messageHeader().build();
// }
//
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/trading/builder/IEXTradeMessageDataBuilder.java
// public static IEXTradeMessage defaultTradeMessage() {
// return tradeMessage().build();
// }
|
import org.junit.jupiter.api.Test;
import java.util.List;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static pl.zankowski.iextrading4j.hist.api.message.builder.IEXMessageHeaderDataBuilder.defaultMessageHeader;
import static pl.zankowski.iextrading4j.hist.api.message.trading.builder.IEXTradeMessageDataBuilder.defaultTradeMessage;
|
package pl.zankowski.iextrading4j.hist.api.message;
class IEXSegmentTest {
@Test
void shouldSuccessfullyCreateSegmentInstance() {
final IEXMessageHeader iexMessageHeader = defaultMessageHeader();
|
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/builder/IEXMessageHeaderDataBuilder.java
// public static IEXMessageHeader defaultMessageHeader() {
// return messageHeader().build();
// }
//
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/trading/builder/IEXTradeMessageDataBuilder.java
// public static IEXTradeMessage defaultTradeMessage() {
// return tradeMessage().build();
// }
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/IEXSegmentTest.java
import org.junit.jupiter.api.Test;
import java.util.List;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static pl.zankowski.iextrading4j.hist.api.message.builder.IEXMessageHeaderDataBuilder.defaultMessageHeader;
import static pl.zankowski.iextrading4j.hist.api.message.trading.builder.IEXTradeMessageDataBuilder.defaultTradeMessage;
package pl.zankowski.iextrading4j.hist.api.message;
class IEXSegmentTest {
@Test
void shouldSuccessfullyCreateSegmentInstance() {
final IEXMessageHeader iexMessageHeader = defaultMessageHeader();
|
final List<IEXMessage> iexMessageList = asList(defaultTradeMessage(), defaultTradeMessage());
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXDetail.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXDetail implements IEXByteEnum {
NO_PRICE_TEST((byte) 0x20),
PRICE_TEST_RESTRICTION_IN_EFFECT((byte) 0x41),
PRICE_TEST_RESTRICTION_REMAINS((byte) 0x43),
PRICE_TEST_RESTRICTION_DEACTIVATED((byte) 0x44),
DETAIL_NOT_AVAILABLE((byte) 0x4e);
private static final Map<Byte, IEXDetail> LOOKUP = new HashMap<>();
static {
for (final IEXDetail value : EnumSet.allOf(IEXDetail.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXDetail(final byte code) {
this.code = code;
}
public static IEXDetail getDetail(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXDetail.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXDetail implements IEXByteEnum {
NO_PRICE_TEST((byte) 0x20),
PRICE_TEST_RESTRICTION_IN_EFFECT((byte) 0x41),
PRICE_TEST_RESTRICTION_REMAINS((byte) 0x43),
PRICE_TEST_RESTRICTION_DEACTIVATED((byte) 0x44),
DETAIL_NOT_AVAILABLE((byte) 0x4e);
private static final Map<Byte, IEXDetail> LOOKUP = new HashMap<>();
static {
for (final IEXDetail value : EnumSet.allOf(IEXDetail.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXDetail(final byte code) {
this.code = code;
}
public static IEXDetail getDetail(final byte code) {
|
return lookup(IEXDetail.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXLULDTier.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXLULDTier implements IEXByteEnum {
NOT_APPLICABLE((byte) 0x0),
TIER_1_NMS((byte) 0x1),
TIER_2_NMS((byte) 0x2);
private static final Map<Byte, IEXLULDTier> LOOKUP = new HashMap<>();
static {
for (final IEXLULDTier value : EnumSet.allOf(IEXLULDTier.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXLULDTier(final byte code) {
this.code = code;
}
public static IEXLULDTier getLULDTier(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXLULDTier.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXLULDTier implements IEXByteEnum {
NOT_APPLICABLE((byte) 0x0),
TIER_1_NMS((byte) 0x1),
TIER_2_NMS((byte) 0x2);
private static final Map<Byte, IEXLULDTier> LOOKUP = new HashMap<>();
static {
for (final IEXLULDTier value : EnumSet.allOf(IEXLULDTier.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXLULDTier(final byte code) {
this.code = code;
}
public static IEXLULDTier getLULDTier(final byte code) {
|
return lookup(IEXLULDTier.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/LotsOfFieldsBenchmark.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/auction/IEXAuctionInformationMessage.java
// public static IEXAuctionInformationMessage createIEXMessage(final byte[] bytes) {
// final IEXAuctionType auctionType = IEXAuctionType.getAuctionType(bytes[1]);
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
// final int pairedShares = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 18, 22));
// final IEXPrice referencePrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 22, 30));
// final IEXPrice indicativeClearingPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 30, 38));
// final int imbalanceShares = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 38, 42));
// final IEXSide imbalanceSide = IEXSide.getSide(bytes[42]);
// final byte extensionNumber = bytes[43];
// final int scheduledAuctionTime = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 44, 48));
// final IEXPrice auctionBookClearingPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 48, 56));
// final IEXPrice collarReferencePrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 56, 64));
// final IEXPrice lowerAuctionCollar = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 64, 72));
// final IEXPrice upperAuctionCollar = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 72, 80));
//
// return new IEXAuctionInformationMessage(auctionType, timestamp, symbol, pairedShares, referencePrice, indicativeClearingPrice,
// imbalanceShares, imbalanceSide, extensionNumber, scheduledAuctionTime, auctionBookClearingPrice, collarReferencePrice,
// lowerAuctionCollar, upperAuctionCollar);
// }
|
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.api.message.auction.IEXAuctionInformationMessage.createIEXMessage;
|
package pl.zankowski.iextrading4j.hist.perf;
public class LotsOfFieldsBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("LotsOfFieldsMessage.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/auction/IEXAuctionInformationMessage.java
// public static IEXAuctionInformationMessage createIEXMessage(final byte[] bytes) {
// final IEXAuctionType auctionType = IEXAuctionType.getAuctionType(bytes[1]);
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
// final int pairedShares = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 18, 22));
// final IEXPrice referencePrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 22, 30));
// final IEXPrice indicativeClearingPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 30, 38));
// final int imbalanceShares = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 38, 42));
// final IEXSide imbalanceSide = IEXSide.getSide(bytes[42]);
// final byte extensionNumber = bytes[43];
// final int scheduledAuctionTime = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 44, 48));
// final IEXPrice auctionBookClearingPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 48, 56));
// final IEXPrice collarReferencePrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 56, 64));
// final IEXPrice lowerAuctionCollar = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 64, 72));
// final IEXPrice upperAuctionCollar = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 72, 80));
//
// return new IEXAuctionInformationMessage(auctionType, timestamp, symbol, pairedShares, referencePrice, indicativeClearingPrice,
// imbalanceShares, imbalanceSide, extensionNumber, scheduledAuctionTime, auctionBookClearingPrice, collarReferencePrice,
// lowerAuctionCollar, upperAuctionCollar);
// }
// Path: iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/LotsOfFieldsBenchmark.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.api.message.auction.IEXAuctionInformationMessage.createIEXMessage;
package pl.zankowski.iextrading4j.hist.perf;
public class LotsOfFieldsBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("LotsOfFieldsMessage.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
public IEXMessage lotsOfFieldsBenchmark(final LotsOfFieldsBenchmark.BenchmarkState benchmarkState) {
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/LotsOfFieldsBenchmark.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/auction/IEXAuctionInformationMessage.java
// public static IEXAuctionInformationMessage createIEXMessage(final byte[] bytes) {
// final IEXAuctionType auctionType = IEXAuctionType.getAuctionType(bytes[1]);
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
// final int pairedShares = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 18, 22));
// final IEXPrice referencePrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 22, 30));
// final IEXPrice indicativeClearingPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 30, 38));
// final int imbalanceShares = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 38, 42));
// final IEXSide imbalanceSide = IEXSide.getSide(bytes[42]);
// final byte extensionNumber = bytes[43];
// final int scheduledAuctionTime = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 44, 48));
// final IEXPrice auctionBookClearingPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 48, 56));
// final IEXPrice collarReferencePrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 56, 64));
// final IEXPrice lowerAuctionCollar = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 64, 72));
// final IEXPrice upperAuctionCollar = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 72, 80));
//
// return new IEXAuctionInformationMessage(auctionType, timestamp, symbol, pairedShares, referencePrice, indicativeClearingPrice,
// imbalanceShares, imbalanceSide, extensionNumber, scheduledAuctionTime, auctionBookClearingPrice, collarReferencePrice,
// lowerAuctionCollar, upperAuctionCollar);
// }
|
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.api.message.auction.IEXAuctionInformationMessage.createIEXMessage;
|
package pl.zankowski.iextrading4j.hist.perf;
public class LotsOfFieldsBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("LotsOfFieldsMessage.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public IEXMessage lotsOfFieldsBenchmark(final LotsOfFieldsBenchmark.BenchmarkState benchmarkState) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/auction/IEXAuctionInformationMessage.java
// public static IEXAuctionInformationMessage createIEXMessage(final byte[] bytes) {
// final IEXAuctionType auctionType = IEXAuctionType.getAuctionType(bytes[1]);
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
// final int pairedShares = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 18, 22));
// final IEXPrice referencePrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 22, 30));
// final IEXPrice indicativeClearingPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 30, 38));
// final int imbalanceShares = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 38, 42));
// final IEXSide imbalanceSide = IEXSide.getSide(bytes[42]);
// final byte extensionNumber = bytes[43];
// final int scheduledAuctionTime = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 44, 48));
// final IEXPrice auctionBookClearingPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 48, 56));
// final IEXPrice collarReferencePrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 56, 64));
// final IEXPrice lowerAuctionCollar = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 64, 72));
// final IEXPrice upperAuctionCollar = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 72, 80));
//
// return new IEXAuctionInformationMessage(auctionType, timestamp, symbol, pairedShares, referencePrice, indicativeClearingPrice,
// imbalanceShares, imbalanceSide, extensionNumber, scheduledAuctionTime, auctionBookClearingPrice, collarReferencePrice,
// lowerAuctionCollar, upperAuctionCollar);
// }
// Path: iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/LotsOfFieldsBenchmark.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.api.message.auction.IEXAuctionInformationMessage.createIEXMessage;
package pl.zankowski.iextrading4j.hist.perf;
public class LotsOfFieldsBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("LotsOfFieldsMessage.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public IEXMessage lotsOfFieldsBenchmark(final LotsOfFieldsBenchmark.BenchmarkState benchmarkState) {
|
return createIEXMessage(benchmarkState.packet);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteTestUtil.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
|
static byte[] convert(final String value) {
return convert(value, 8);
}
public static byte[] convert(final String value, final int capacity) {
final ByteBuffer buffer = ByteBuffer.allocate(capacity);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.put(value.getBytes());
return buffer.array();
}
public static byte[] convertUnsignedShort(final int value) {
final ByteBuffer buffer = ByteBuffer.allocate(2);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.putShort((short) value);
return buffer.array();
}
public static byte[] prepareBytes(final int capacity, final Object... objects) {
final ByteBuffer byteBuffer = ByteBuffer.allocate(capacity);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
for (final Object object : objects) {
if (object instanceof Long) {
byteBuffer.put(convert((Long) object));
} else if (object instanceof Short) {
byteBuffer.put(convert((Short) object));
} else if (object instanceof Integer) {
byteBuffer.put(convert((Integer) object));
} else if (object instanceof String) {
byteBuffer.put(convert((String) object));
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteTestUtil.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
static byte[] convert(final String value) {
return convert(value, 8);
}
public static byte[] convert(final String value, final int capacity) {
final ByteBuffer buffer = ByteBuffer.allocate(capacity);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.put(value.getBytes());
return buffer.array();
}
public static byte[] convertUnsignedShort(final int value) {
final ByteBuffer buffer = ByteBuffer.allocate(2);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.putShort((short) value);
return buffer.array();
}
public static byte[] prepareBytes(final int capacity, final Object... objects) {
final ByteBuffer byteBuffer = ByteBuffer.allocate(capacity);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
for (final Object object : objects) {
if (object instanceof Long) {
byteBuffer.put(convert((Long) object));
} else if (object instanceof Short) {
byteBuffer.put(convert((Short) object));
} else if (object instanceof Integer) {
byteBuffer.put(convert((Integer) object));
} else if (object instanceof String) {
byteBuffer.put(convert((String) object));
|
} else if (object instanceof IEXByteEnum) {
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteTestUtil.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
|
}
public static byte[] convert(final String value, final int capacity) {
final ByteBuffer buffer = ByteBuffer.allocate(capacity);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.put(value.getBytes());
return buffer.array();
}
public static byte[] convertUnsignedShort(final int value) {
final ByteBuffer buffer = ByteBuffer.allocate(2);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.putShort((short) value);
return buffer.array();
}
public static byte[] prepareBytes(final int capacity, final Object... objects) {
final ByteBuffer byteBuffer = ByteBuffer.allocate(capacity);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
for (final Object object : objects) {
if (object instanceof Long) {
byteBuffer.put(convert((Long) object));
} else if (object instanceof Short) {
byteBuffer.put(convert((Short) object));
} else if (object instanceof Integer) {
byteBuffer.put(convert((Integer) object));
} else if (object instanceof String) {
byteBuffer.put(convert((String) object));
} else if (object instanceof IEXByteEnum) {
byteBuffer.put(((IEXByteEnum) object).getCode());
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteTestUtil.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
}
public static byte[] convert(final String value, final int capacity) {
final ByteBuffer buffer = ByteBuffer.allocate(capacity);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.put(value.getBytes());
return buffer.array();
}
public static byte[] convertUnsignedShort(final int value) {
final ByteBuffer buffer = ByteBuffer.allocate(2);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.putShort((short) value);
return buffer.array();
}
public static byte[] prepareBytes(final int capacity, final Object... objects) {
final ByteBuffer byteBuffer = ByteBuffer.allocate(capacity);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
for (final Object object : objects) {
if (object instanceof Long) {
byteBuffer.put(convert((Long) object));
} else if (object instanceof Short) {
byteBuffer.put(convert((Short) object));
} else if (object instanceof Integer) {
byteBuffer.put(convert((Integer) object));
} else if (object instanceof String) {
byteBuffer.put(convert((String) object));
} else if (object instanceof IEXByteEnum) {
byteBuffer.put(((IEXByteEnum) object).getCode());
|
} else if (object instanceof IEXPrice) {
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-tops/src/main/java/pl/zankowski/iextrading4j/hist/tops/trading/IEXQuoteUpdateMessage.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.QUOTE_UPDATE;
|
package pl.zankowski.iextrading4j.hist.tops.trading;
public class IEXQuoteUpdateMessage extends IEXMessage {
public static final int LENGTH = 42;
private final byte flag;
private final long timestamp;
private final String symbol;
private final int bidSize;
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
// Path: iextrading4j-hist-tops/src/main/java/pl/zankowski/iextrading4j/hist/tops/trading/IEXQuoteUpdateMessage.java
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.QUOTE_UPDATE;
package pl.zankowski.iextrading4j.hist.tops.trading;
public class IEXQuoteUpdateMessage extends IEXMessage {
public static final int LENGTH = 42;
private final byte flag;
private final long timestamp;
private final String symbol;
private final int bidSize;
|
private final IEXPrice bidPrice;
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-tops/src/main/java/pl/zankowski/iextrading4j/hist/tops/trading/IEXQuoteUpdateMessage.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.QUOTE_UPDATE;
|
package pl.zankowski.iextrading4j.hist.tops.trading;
public class IEXQuoteUpdateMessage extends IEXMessage {
public static final int LENGTH = 42;
private final byte flag;
private final long timestamp;
private final String symbol;
private final int bidSize;
private final IEXPrice bidPrice;
private final IEXPrice askPrice;
private final int askSize;
private IEXQuoteUpdateMessage(
final byte flag,
final long timestamp,
final String symbol,
final int bidSize,
final IEXPrice bidPrice,
final IEXPrice askPrice,
final int askSize) {
super(QUOTE_UPDATE);
this.flag = flag;
this.timestamp = timestamp;
this.symbol = symbol;
this.bidSize = bidSize;
this.bidPrice = bidPrice;
this.askPrice = askPrice;
this.askSize = askSize;
}
public static IEXQuoteUpdateMessage createIEXMessage(final byte[] bytes) {
final byte flag = bytes[1];
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
// Path: iextrading4j-hist-tops/src/main/java/pl/zankowski/iextrading4j/hist/tops/trading/IEXQuoteUpdateMessage.java
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.QUOTE_UPDATE;
package pl.zankowski.iextrading4j.hist.tops.trading;
public class IEXQuoteUpdateMessage extends IEXMessage {
public static final int LENGTH = 42;
private final byte flag;
private final long timestamp;
private final String symbol;
private final int bidSize;
private final IEXPrice bidPrice;
private final IEXPrice askPrice;
private final int askSize;
private IEXQuoteUpdateMessage(
final byte flag,
final long timestamp,
final String symbol,
final int bidSize,
final IEXPrice bidPrice,
final IEXPrice askPrice,
final int askSize) {
super(QUOTE_UPDATE);
this.flag = flag;
this.timestamp = timestamp;
this.symbol = symbol;
this.bidSize = bidSize;
this.bidPrice = bidPrice;
this.askPrice = askPrice;
this.askSize = askSize;
}
public static IEXQuoteUpdateMessage createIEXMessage(final byte[] bytes) {
final byte flag = bytes[1];
|
final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/auction/field/IEXSide.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.api.message.auction.field;
public enum IEXSide implements IEXByteEnum {
BUY_IMBALANCE((byte) 0x42),
SELL_IMBALANCE((byte) 0x53),
NO_IMBALANCE((byte) 0x4e);
private static final Map<Byte, IEXSide> LOOKUP = new HashMap<>();
static {
for (final IEXSide value : EnumSet.allOf(IEXSide.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXSide(final byte code) {
this.code = code;
}
public static IEXSide getSide(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/auction/field/IEXSide.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.api.message.auction.field;
public enum IEXSide implements IEXByteEnum {
BUY_IMBALANCE((byte) 0x42),
SELL_IMBALANCE((byte) 0x53),
NO_IMBALANCE((byte) 0x4e);
private static final Map<Byte, IEXSide> LOOKUP = new HashMap<>();
static {
for (final IEXSide value : EnumSet.allOf(IEXSide.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXSide(final byte code) {
this.code = code;
}
public static IEXSide getSide(final byte code) {
|
return lookup(IEXSide.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXSystemEventMessage.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXSystemEvent.java
// public enum IEXSystemEvent implements IEXByteEnum {
//
// MESSAGES_START((byte) 0x4f),
// SYSTEM_HOURS_START((byte) 0x53),
// REGULAR_MARKET_HOURS_START((byte) 0x52),
// REGULAR_MARKET_HOURS_END((byte) 0x4d),
// SYSTEM_HOURS_END((byte) 0x45),
// MESSAGES_END((byte) 0x43);
//
// private static final Map<Byte, IEXSystemEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSystemEvent value : EnumSet.allOf(IEXSystemEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSystemEvent(final byte code) {
// this.code = code;
// }
//
// public static IEXSystemEvent getSystemEvent(final byte code) {
// return lookup(IEXSystemEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXSystemEvent;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.SYSTEM_EVENT;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXSystemEventMessage extends IEXMessage {
public static final int LENGTH = 10;
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXSystemEvent.java
// public enum IEXSystemEvent implements IEXByteEnum {
//
// MESSAGES_START((byte) 0x4f),
// SYSTEM_HOURS_START((byte) 0x53),
// REGULAR_MARKET_HOURS_START((byte) 0x52),
// REGULAR_MARKET_HOURS_END((byte) 0x4d),
// SYSTEM_HOURS_END((byte) 0x45),
// MESSAGES_END((byte) 0x43);
//
// private static final Map<Byte, IEXSystemEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSystemEvent value : EnumSet.allOf(IEXSystemEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSystemEvent(final byte code) {
// this.code = code;
// }
//
// public static IEXSystemEvent getSystemEvent(final byte code) {
// return lookup(IEXSystemEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXSystemEventMessage.java
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXSystemEvent;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.SYSTEM_EVENT;
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXSystemEventMessage extends IEXMessage {
public static final int LENGTH = 10;
|
private final IEXSystemEvent systemEvent;
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXSystemEventMessage.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXSystemEvent.java
// public enum IEXSystemEvent implements IEXByteEnum {
//
// MESSAGES_START((byte) 0x4f),
// SYSTEM_HOURS_START((byte) 0x53),
// REGULAR_MARKET_HOURS_START((byte) 0x52),
// REGULAR_MARKET_HOURS_END((byte) 0x4d),
// SYSTEM_HOURS_END((byte) 0x45),
// MESSAGES_END((byte) 0x43);
//
// private static final Map<Byte, IEXSystemEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSystemEvent value : EnumSet.allOf(IEXSystemEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSystemEvent(final byte code) {
// this.code = code;
// }
//
// public static IEXSystemEvent getSystemEvent(final byte code) {
// return lookup(IEXSystemEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXSystemEvent;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.SYSTEM_EVENT;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXSystemEventMessage extends IEXMessage {
public static final int LENGTH = 10;
private final IEXSystemEvent systemEvent;
private final long timestamp;
private IEXSystemEventMessage(
final IEXSystemEvent systemEvent,
final long timestamp) {
super(SYSTEM_EVENT);
this.systemEvent = systemEvent;
this.timestamp = timestamp;
}
public static IEXSystemEventMessage createIEXMessage(final byte[] bytes) {
final IEXSystemEvent systemEvent = IEXSystemEvent.getSystemEvent(bytes[1]);
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXSystemEvent.java
// public enum IEXSystemEvent implements IEXByteEnum {
//
// MESSAGES_START((byte) 0x4f),
// SYSTEM_HOURS_START((byte) 0x53),
// REGULAR_MARKET_HOURS_START((byte) 0x52),
// REGULAR_MARKET_HOURS_END((byte) 0x4d),
// SYSTEM_HOURS_END((byte) 0x45),
// MESSAGES_END((byte) 0x43);
//
// private static final Map<Byte, IEXSystemEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSystemEvent value : EnumSet.allOf(IEXSystemEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSystemEvent(final byte code) {
// this.code = code;
// }
//
// public static IEXSystemEvent getSystemEvent(final byte code) {
// return lookup(IEXSystemEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXSystemEventMessage.java
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXSystemEvent;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.SYSTEM_EVENT;
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXSystemEventMessage extends IEXMessage {
public static final int LENGTH = 10;
private final IEXSystemEvent systemEvent;
private final long timestamp;
private IEXSystemEventMessage(
final IEXSystemEvent systemEvent,
final long timestamp) {
super(SYSTEM_EVENT);
this.systemEvent = systemEvent;
this.timestamp = timestamp;
}
public static IEXSystemEventMessage createIEXMessage(final byte[] bytes) {
final IEXSystemEvent systemEvent = IEXSystemEvent.getSystemEvent(bytes[1]);
|
final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/exception/IEXMessageException.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
|
package pl.zankowski.iextrading4j.hist.api.exception;
public class IEXMessageException extends RuntimeException {
public IEXMessageException(final String message) {
super(message);
}
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/exception/IEXMessageException.java
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
package pl.zankowski.iextrading4j.hist.api.exception;
public class IEXMessageException extends RuntimeException {
public IEXMessageException(final String message) {
super(message);
}
|
public IEXMessageException(final Class<? extends IEXMessage> clazz, final int length) {
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXSystemEvent.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXSystemEvent implements IEXByteEnum {
MESSAGES_START((byte) 0x4f),
SYSTEM_HOURS_START((byte) 0x53),
REGULAR_MARKET_HOURS_START((byte) 0x52),
REGULAR_MARKET_HOURS_END((byte) 0x4d),
SYSTEM_HOURS_END((byte) 0x45),
MESSAGES_END((byte) 0x43);
private static final Map<Byte, IEXSystemEvent> LOOKUP = new HashMap<>();
static {
for (final IEXSystemEvent value : EnumSet.allOf(IEXSystemEvent.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXSystemEvent(final byte code) {
this.code = code;
}
public static IEXSystemEvent getSystemEvent(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXSystemEvent.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXSystemEvent implements IEXByteEnum {
MESSAGES_START((byte) 0x4f),
SYSTEM_HOURS_START((byte) 0x53),
REGULAR_MARKET_HOURS_START((byte) 0x52),
REGULAR_MARKET_HOURS_END((byte) 0x4d),
SYSTEM_HOURS_END((byte) 0x45),
MESSAGES_END((byte) 0x43);
private static final Map<Byte, IEXSystemEvent> LOOKUP = new HashMap<>();
static {
for (final IEXSystemEvent value : EnumSet.allOf(IEXSystemEvent.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXSystemEvent(final byte code) {
this.code = code;
}
public static IEXSystemEvent getSystemEvent(final byte code) {
|
return lookup(IEXSystemEvent.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
|
public static int convertBytesToInt(final byte[] bytes) {
return ((0xff & bytes[3]) << 24 |
(0xff & bytes[2]) << 16 |
(0xff & bytes[1]) << 8 |
(0xff & bytes[0]) << 0
);
}
public static byte[] toByteArray(int value) {
return new byte[]{
(byte) value,
(byte) (value >> 8 & 0xFF),
(byte) (value >> 16 & 0xFF),
(byte) (value >> 24 & 0xFF)};
}
public static int convertBytesToUnsignedShort(final byte[] bytes) {
return convertBytesToShort(bytes) & 0xffff;
}
public static short convertBytesToShort(final byte[] bytes) {
return (short) (
(0xff & bytes[1]) << 8 |
(0xff & bytes[0]) << 0);
}
public static String convertBytesToString(final byte[] bytes) {
return new String(bytes).trim();
}
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
public static int convertBytesToInt(final byte[] bytes) {
return ((0xff & bytes[3]) << 24 |
(0xff & bytes[2]) << 16 |
(0xff & bytes[1]) << 8 |
(0xff & bytes[0]) << 0
);
}
public static byte[] toByteArray(int value) {
return new byte[]{
(byte) value,
(byte) (value >> 8 & 0xFF),
(byte) (value >> 16 & 0xFF),
(byte) (value >> 24 & 0xFF)};
}
public static int convertBytesToUnsignedShort(final byte[] bytes) {
return convertBytesToShort(bytes) & 0xffff;
}
public static short convertBytesToShort(final byte[] bytes) {
return (short) (
(0xff & bytes[1]) << 8 |
(0xff & bytes[0]) << 0);
}
public static String convertBytesToString(final byte[] bytes) {
return new String(bytes).trim();
}
|
public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/IEXSecurityEventMessage.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/field/IEXSecurityEvent.java
// public enum IEXSecurityEvent implements IEXByteEnum {
//
// OPENING_PROCESS_COMPLETE((byte) 0x4f),
// CLOSING_PROCESS_COMPLETE((byte) 0x43);
//
// private static final Map<Byte, IEXSecurityEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSecurityEvent value : EnumSet.allOf(IEXSecurityEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSecurityEvent(byte code) {
// this.code = code;
// }
//
// public static IEXSecurityEvent getSecurityEvent(final byte code) {
// return lookup(IEXSecurityEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
|
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import pl.zankowski.iextrading4j.hist.deep.administrative.field.IEXSecurityEvent;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.SECURITY_EVENT;
|
package pl.zankowski.iextrading4j.hist.deep.administrative;
public class IEXSecurityEventMessage extends IEXMessage {
public static final int LENGTH = 18;
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/field/IEXSecurityEvent.java
// public enum IEXSecurityEvent implements IEXByteEnum {
//
// OPENING_PROCESS_COMPLETE((byte) 0x4f),
// CLOSING_PROCESS_COMPLETE((byte) 0x43);
//
// private static final Map<Byte, IEXSecurityEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSecurityEvent value : EnumSet.allOf(IEXSecurityEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSecurityEvent(byte code) {
// this.code = code;
// }
//
// public static IEXSecurityEvent getSecurityEvent(final byte code) {
// return lookup(IEXSecurityEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/IEXSecurityEventMessage.java
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import pl.zankowski.iextrading4j.hist.deep.administrative.field.IEXSecurityEvent;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.SECURITY_EVENT;
package pl.zankowski.iextrading4j.hist.deep.administrative;
public class IEXSecurityEventMessage extends IEXMessage {
public static final int LENGTH = 18;
|
private final IEXSecurityEvent securityEvent;
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/IEXSecurityEventMessage.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/field/IEXSecurityEvent.java
// public enum IEXSecurityEvent implements IEXByteEnum {
//
// OPENING_PROCESS_COMPLETE((byte) 0x4f),
// CLOSING_PROCESS_COMPLETE((byte) 0x43);
//
// private static final Map<Byte, IEXSecurityEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSecurityEvent value : EnumSet.allOf(IEXSecurityEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSecurityEvent(byte code) {
// this.code = code;
// }
//
// public static IEXSecurityEvent getSecurityEvent(final byte code) {
// return lookup(IEXSecurityEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
|
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import pl.zankowski.iextrading4j.hist.deep.administrative.field.IEXSecurityEvent;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.SECURITY_EVENT;
|
package pl.zankowski.iextrading4j.hist.deep.administrative;
public class IEXSecurityEventMessage extends IEXMessage {
public static final int LENGTH = 18;
private final IEXSecurityEvent securityEvent;
private final long timestamp;
private final String symbol;
private IEXSecurityEventMessage(
final IEXSecurityEvent securityEvent,
final long timestamp,
final String symbol) {
super(SECURITY_EVENT);
this.securityEvent = securityEvent;
this.timestamp = timestamp;
this.symbol = symbol;
}
public static IEXSecurityEventMessage createIEXMessage(final byte[] bytes) {
final IEXSecurityEvent iexSecurityEvent = IEXSecurityEvent.getSecurityEvent(bytes[1]);
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/field/IEXSecurityEvent.java
// public enum IEXSecurityEvent implements IEXByteEnum {
//
// OPENING_PROCESS_COMPLETE((byte) 0x4f),
// CLOSING_PROCESS_COMPLETE((byte) 0x43);
//
// private static final Map<Byte, IEXSecurityEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSecurityEvent value : EnumSet.allOf(IEXSecurityEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSecurityEvent(byte code) {
// this.code = code;
// }
//
// public static IEXSecurityEvent getSecurityEvent(final byte code) {
// return lookup(IEXSecurityEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/IEXSecurityEventMessage.java
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import pl.zankowski.iextrading4j.hist.deep.administrative.field.IEXSecurityEvent;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.SECURITY_EVENT;
package pl.zankowski.iextrading4j.hist.deep.administrative;
public class IEXSecurityEventMessage extends IEXMessage {
public static final int LENGTH = 18;
private final IEXSecurityEvent securityEvent;
private final long timestamp;
private final String symbol;
private IEXSecurityEventMessage(
final IEXSecurityEvent securityEvent,
final long timestamp,
final String symbol) {
super(SECURITY_EVENT);
this.securityEvent = securityEvent;
this.timestamp = timestamp;
this.symbol = symbol;
}
public static IEXSecurityEventMessage createIEXMessage(final byte[] bytes) {
final IEXSecurityEvent iexSecurityEvent = IEXSecurityEvent.getSecurityEvent(bytes[1]);
|
final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXTradingStatus.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXTradingStatus implements IEXByteEnum {
TRADING_HALTED((byte) 0x48),
ORDER_ACCEPTANCE_PERIOD((byte) 0x4f),
ORDER_ACCEPTANCE_PERIOD_ON_IEX((byte) 0x50),
TRADING_ON_IEX((byte) 0x54);
private static final Map<Byte, IEXTradingStatus> LOOKUP = new HashMap<>();
static {
for (final IEXTradingStatus value : EnumSet.allOf(IEXTradingStatus.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXTradingStatus(final byte code) {
this.code = code;
}
public static IEXTradingStatus getTradingStatus(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXTradingStatus.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXTradingStatus implements IEXByteEnum {
TRADING_HALTED((byte) 0x48),
ORDER_ACCEPTANCE_PERIOD((byte) 0x4f),
ORDER_ACCEPTANCE_PERIOD_ON_IEX((byte) 0x50),
TRADING_ON_IEX((byte) 0x54);
private static final Map<Byte, IEXTradingStatus> LOOKUP = new HashMap<>();
static {
for (final IEXTradingStatus value : EnumSet.allOf(IEXTradingStatus.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXTradingStatus(final byte code) {
this.code = code;
}
public static IEXTradingStatus getTradingStatus(final byte code) {
|
return lookup(IEXTradingStatus.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXOperationalHaltStatus.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXOperationalHaltStatus implements IEXByteEnum {
OPERATIONAL_TRADING_HALt((byte) 0x4f),
NOT_OPERATIONAL_HALTED((byte) 0x4e);
private static final Map<Byte, IEXOperationalHaltStatus> LOOKUP = new HashMap<>();
static {
for (final IEXOperationalHaltStatus value : EnumSet.allOf(IEXOperationalHaltStatus.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXOperationalHaltStatus(final byte code) {
this.code = code;
}
public static IEXOperationalHaltStatus getOperationalHaltStatus(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXOperationalHaltStatus.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXOperationalHaltStatus implements IEXByteEnum {
OPERATIONAL_TRADING_HALt((byte) 0x4f),
NOT_OPERATIONAL_HALTED((byte) 0x4e);
private static final Map<Byte, IEXOperationalHaltStatus> LOOKUP = new HashMap<>();
static {
for (final IEXOperationalHaltStatus value : EnumSet.allOf(IEXOperationalHaltStatus.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXOperationalHaltStatus(final byte code) {
this.code = code;
}
public static IEXOperationalHaltStatus getOperationalHaltStatus(final byte code) {
|
return lookup(IEXOperationalHaltStatus.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessageHeaderTest.java
|
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteTestUtil.java
// public class IEXByteTestUtil {
//
// static byte[] convert(final long value) {
// final ByteBuffer buffer = ByteBuffer.allocate(8);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putLong(value);
// return buffer.array();
// }
//
// public static byte[] convert(final short value) {
// final ByteBuffer buffer = ByteBuffer.allocate(2);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putShort(value);
// return buffer.array();
// }
//
// static byte[] convert(final int value) {
// final ByteBuffer buffer = ByteBuffer.allocate(4);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putInt(value);
// return buffer.array();
// }
//
// static byte[] convert(final String value) {
// return convert(value, 8);
// }
//
// public static byte[] convert(final String value, final int capacity) {
// final ByteBuffer buffer = ByteBuffer.allocate(capacity);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.put(value.getBytes());
// return buffer.array();
// }
//
// public static byte[] convertUnsignedShort(final int value) {
// final ByteBuffer buffer = ByteBuffer.allocate(2);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putShort((short) value);
// return buffer.array();
// }
//
// public static byte[] prepareBytes(final int capacity, final Object... objects) {
// final ByteBuffer byteBuffer = ByteBuffer.allocate(capacity);
// byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
// for (final Object object : objects) {
// if (object instanceof Long) {
// byteBuffer.put(convert((Long) object));
// } else if (object instanceof Short) {
// byteBuffer.put(convert((Short) object));
// } else if (object instanceof Integer) {
// byteBuffer.put(convert((Integer) object));
// } else if (object instanceof String) {
// byteBuffer.put(convert((String) object));
// } else if (object instanceof IEXByteEnum) {
// byteBuffer.put(((IEXByteEnum) object).getCode());
// } else if (object instanceof IEXPrice) {
// byteBuffer.put(convert(((IEXPrice) object).getNumber()));
// } else if (object instanceof byte[]) {
// byteBuffer.put((byte[]) object);
// } else {
// byteBuffer.put((Byte) object);
// }
// }
// return byteBuffer.array();
// }
//
//
// }
//
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/builder/IEXMessageHeaderDataBuilder.java
// public static IEXMessageHeader defaultMessageHeader() {
// return messageHeader().build();
// }
|
import org.junit.jupiter.api.Test;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteTestUtil;
import static org.assertj.core.api.Assertions.assertThat;
import static pl.zankowski.iextrading4j.hist.api.message.builder.IEXMessageHeaderDataBuilder.defaultMessageHeader;
|
package pl.zankowski.iextrading4j.hist.api.message;
class IEXMessageHeaderTest {
@Test
void shouldSuccessfullyCreateMessageHeader() {
final byte version = 1;
final byte reserved = 1;
final IEXMessageProtocol messageProtocolId = IEXMessageProtocol.TOPS_1_5;
final int channelID = 1;
final int sessionID = 1133838336;
final short payloadLength = 44;
final short messageCount = 1;
final long streamOffset = 5076984;
final long firstMessageSequenceNumber = 115387;
final long sendTime = 1494855059287436131L;
|
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteTestUtil.java
// public class IEXByteTestUtil {
//
// static byte[] convert(final long value) {
// final ByteBuffer buffer = ByteBuffer.allocate(8);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putLong(value);
// return buffer.array();
// }
//
// public static byte[] convert(final short value) {
// final ByteBuffer buffer = ByteBuffer.allocate(2);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putShort(value);
// return buffer.array();
// }
//
// static byte[] convert(final int value) {
// final ByteBuffer buffer = ByteBuffer.allocate(4);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putInt(value);
// return buffer.array();
// }
//
// static byte[] convert(final String value) {
// return convert(value, 8);
// }
//
// public static byte[] convert(final String value, final int capacity) {
// final ByteBuffer buffer = ByteBuffer.allocate(capacity);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.put(value.getBytes());
// return buffer.array();
// }
//
// public static byte[] convertUnsignedShort(final int value) {
// final ByteBuffer buffer = ByteBuffer.allocate(2);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putShort((short) value);
// return buffer.array();
// }
//
// public static byte[] prepareBytes(final int capacity, final Object... objects) {
// final ByteBuffer byteBuffer = ByteBuffer.allocate(capacity);
// byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
// for (final Object object : objects) {
// if (object instanceof Long) {
// byteBuffer.put(convert((Long) object));
// } else if (object instanceof Short) {
// byteBuffer.put(convert((Short) object));
// } else if (object instanceof Integer) {
// byteBuffer.put(convert((Integer) object));
// } else if (object instanceof String) {
// byteBuffer.put(convert((String) object));
// } else if (object instanceof IEXByteEnum) {
// byteBuffer.put(((IEXByteEnum) object).getCode());
// } else if (object instanceof IEXPrice) {
// byteBuffer.put(convert(((IEXPrice) object).getNumber()));
// } else if (object instanceof byte[]) {
// byteBuffer.put((byte[]) object);
// } else {
// byteBuffer.put((Byte) object);
// }
// }
// return byteBuffer.array();
// }
//
//
// }
//
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/builder/IEXMessageHeaderDataBuilder.java
// public static IEXMessageHeader defaultMessageHeader() {
// return messageHeader().build();
// }
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessageHeaderTest.java
import org.junit.jupiter.api.Test;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteTestUtil;
import static org.assertj.core.api.Assertions.assertThat;
import static pl.zankowski.iextrading4j.hist.api.message.builder.IEXMessageHeaderDataBuilder.defaultMessageHeader;
package pl.zankowski.iextrading4j.hist.api.message;
class IEXMessageHeaderTest {
@Test
void shouldSuccessfullyCreateMessageHeader() {
final byte version = 1;
final byte reserved = 1;
final IEXMessageProtocol messageProtocolId = IEXMessageProtocol.TOPS_1_5;
final int channelID = 1;
final int sessionID = 1133838336;
final short payloadLength = 44;
final short messageCount = 1;
final long streamOffset = 5076984;
final long firstMessageSequenceNumber = 115387;
final long sendTime = 1494855059287436131L;
|
final byte[] messageProtocolBytes = IEXByteTestUtil.convertUnsignedShort(messageProtocolId.getCode());
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessageHeaderTest.java
|
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteTestUtil.java
// public class IEXByteTestUtil {
//
// static byte[] convert(final long value) {
// final ByteBuffer buffer = ByteBuffer.allocate(8);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putLong(value);
// return buffer.array();
// }
//
// public static byte[] convert(final short value) {
// final ByteBuffer buffer = ByteBuffer.allocate(2);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putShort(value);
// return buffer.array();
// }
//
// static byte[] convert(final int value) {
// final ByteBuffer buffer = ByteBuffer.allocate(4);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putInt(value);
// return buffer.array();
// }
//
// static byte[] convert(final String value) {
// return convert(value, 8);
// }
//
// public static byte[] convert(final String value, final int capacity) {
// final ByteBuffer buffer = ByteBuffer.allocate(capacity);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.put(value.getBytes());
// return buffer.array();
// }
//
// public static byte[] convertUnsignedShort(final int value) {
// final ByteBuffer buffer = ByteBuffer.allocate(2);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putShort((short) value);
// return buffer.array();
// }
//
// public static byte[] prepareBytes(final int capacity, final Object... objects) {
// final ByteBuffer byteBuffer = ByteBuffer.allocate(capacity);
// byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
// for (final Object object : objects) {
// if (object instanceof Long) {
// byteBuffer.put(convert((Long) object));
// } else if (object instanceof Short) {
// byteBuffer.put(convert((Short) object));
// } else if (object instanceof Integer) {
// byteBuffer.put(convert((Integer) object));
// } else if (object instanceof String) {
// byteBuffer.put(convert((String) object));
// } else if (object instanceof IEXByteEnum) {
// byteBuffer.put(((IEXByteEnum) object).getCode());
// } else if (object instanceof IEXPrice) {
// byteBuffer.put(convert(((IEXPrice) object).getNumber()));
// } else if (object instanceof byte[]) {
// byteBuffer.put((byte[]) object);
// } else {
// byteBuffer.put((Byte) object);
// }
// }
// return byteBuffer.array();
// }
//
//
// }
//
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/builder/IEXMessageHeaderDataBuilder.java
// public static IEXMessageHeader defaultMessageHeader() {
// return messageHeader().build();
// }
|
import org.junit.jupiter.api.Test;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteTestUtil;
import static org.assertj.core.api.Assertions.assertThat;
import static pl.zankowski.iextrading4j.hist.api.message.builder.IEXMessageHeaderDataBuilder.defaultMessageHeader;
|
package pl.zankowski.iextrading4j.hist.api.message;
class IEXMessageHeaderTest {
@Test
void shouldSuccessfullyCreateMessageHeader() {
final byte version = 1;
final byte reserved = 1;
final IEXMessageProtocol messageProtocolId = IEXMessageProtocol.TOPS_1_5;
final int channelID = 1;
final int sessionID = 1133838336;
final short payloadLength = 44;
final short messageCount = 1;
final long streamOffset = 5076984;
final long firstMessageSequenceNumber = 115387;
final long sendTime = 1494855059287436131L;
final byte[] messageProtocolBytes = IEXByteTestUtil.convertUnsignedShort(messageProtocolId.getCode());
final byte[] data = IEXByteTestUtil.prepareBytes(IEXMessageHeader.LENGTH, version, reserved, messageProtocolBytes,
channelID, sessionID, payloadLength, messageCount, streamOffset, firstMessageSequenceNumber, sendTime);
final IEXMessageHeader iexMessageHeader = IEXMessageHeader.createIEXMessageHeader(data);
assertThat(iexMessageHeader.getVersion()).isEqualTo(version);
assertThat(iexMessageHeader.getMessageProtocolID()).isEqualTo(messageProtocolId);
assertThat(iexMessageHeader.getChannelID()).isEqualTo(channelID);
assertThat(iexMessageHeader.getSessionID()).isEqualTo(sessionID);
assertThat(iexMessageHeader.getPayloadLength()).isEqualTo(payloadLength);
assertThat(iexMessageHeader.getMessageCount()).isEqualTo(messageCount);
assertThat(iexMessageHeader.getStreamOffset()).isEqualTo(streamOffset);
assertThat(iexMessageHeader.getFirstMessageSequenceNumber()).isEqualTo(firstMessageSequenceNumber);
assertThat(iexMessageHeader.getSendTime()).isEqualTo(sendTime);
}
@Test
void shouldTwoInstancesWithSameValuesBeEqual() {
|
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteTestUtil.java
// public class IEXByteTestUtil {
//
// static byte[] convert(final long value) {
// final ByteBuffer buffer = ByteBuffer.allocate(8);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putLong(value);
// return buffer.array();
// }
//
// public static byte[] convert(final short value) {
// final ByteBuffer buffer = ByteBuffer.allocate(2);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putShort(value);
// return buffer.array();
// }
//
// static byte[] convert(final int value) {
// final ByteBuffer buffer = ByteBuffer.allocate(4);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putInt(value);
// return buffer.array();
// }
//
// static byte[] convert(final String value) {
// return convert(value, 8);
// }
//
// public static byte[] convert(final String value, final int capacity) {
// final ByteBuffer buffer = ByteBuffer.allocate(capacity);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.put(value.getBytes());
// return buffer.array();
// }
//
// public static byte[] convertUnsignedShort(final int value) {
// final ByteBuffer buffer = ByteBuffer.allocate(2);
// buffer.order(ByteOrder.LITTLE_ENDIAN);
// buffer.putShort((short) value);
// return buffer.array();
// }
//
// public static byte[] prepareBytes(final int capacity, final Object... objects) {
// final ByteBuffer byteBuffer = ByteBuffer.allocate(capacity);
// byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
// for (final Object object : objects) {
// if (object instanceof Long) {
// byteBuffer.put(convert((Long) object));
// } else if (object instanceof Short) {
// byteBuffer.put(convert((Short) object));
// } else if (object instanceof Integer) {
// byteBuffer.put(convert((Integer) object));
// } else if (object instanceof String) {
// byteBuffer.put(convert((String) object));
// } else if (object instanceof IEXByteEnum) {
// byteBuffer.put(((IEXByteEnum) object).getCode());
// } else if (object instanceof IEXPrice) {
// byteBuffer.put(convert(((IEXPrice) object).getNumber()));
// } else if (object instanceof byte[]) {
// byteBuffer.put((byte[]) object);
// } else {
// byteBuffer.put((Byte) object);
// }
// }
// return byteBuffer.array();
// }
//
//
// }
//
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/builder/IEXMessageHeaderDataBuilder.java
// public static IEXMessageHeader defaultMessageHeader() {
// return messageHeader().build();
// }
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessageHeaderTest.java
import org.junit.jupiter.api.Test;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteTestUtil;
import static org.assertj.core.api.Assertions.assertThat;
import static pl.zankowski.iextrading4j.hist.api.message.builder.IEXMessageHeaderDataBuilder.defaultMessageHeader;
package pl.zankowski.iextrading4j.hist.api.message;
class IEXMessageHeaderTest {
@Test
void shouldSuccessfullyCreateMessageHeader() {
final byte version = 1;
final byte reserved = 1;
final IEXMessageProtocol messageProtocolId = IEXMessageProtocol.TOPS_1_5;
final int channelID = 1;
final int sessionID = 1133838336;
final short payloadLength = 44;
final short messageCount = 1;
final long streamOffset = 5076984;
final long firstMessageSequenceNumber = 115387;
final long sendTime = 1494855059287436131L;
final byte[] messageProtocolBytes = IEXByteTestUtil.convertUnsignedShort(messageProtocolId.getCode());
final byte[] data = IEXByteTestUtil.prepareBytes(IEXMessageHeader.LENGTH, version, reserved, messageProtocolBytes,
channelID, sessionID, payloadLength, messageCount, streamOffset, firstMessageSequenceNumber, sendTime);
final IEXMessageHeader iexMessageHeader = IEXMessageHeader.createIEXMessageHeader(data);
assertThat(iexMessageHeader.getVersion()).isEqualTo(version);
assertThat(iexMessageHeader.getMessageProtocolID()).isEqualTo(messageProtocolId);
assertThat(iexMessageHeader.getChannelID()).isEqualTo(channelID);
assertThat(iexMessageHeader.getSessionID()).isEqualTo(sessionID);
assertThat(iexMessageHeader.getPayloadLength()).isEqualTo(payloadLength);
assertThat(iexMessageHeader.getMessageCount()).isEqualTo(messageCount);
assertThat(iexMessageHeader.getStreamOffset()).isEqualTo(streamOffset);
assertThat(iexMessageHeader.getFirstMessageSequenceNumber()).isEqualTo(firstMessageSequenceNumber);
assertThat(iexMessageHeader.getSendTime()).isEqualTo(sendTime);
}
@Test
void shouldTwoInstancesWithSameValuesBeEqual() {
|
final IEXMessageHeader iexMessageHeader_1 = defaultMessageHeader();
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessageHeader.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/exception/IEXMessageException.java
// public class IEXMessageException extends RuntimeException {
//
// public IEXMessageException(final String message) {
// super(message);
// }
//
// public IEXMessageException(final Class<? extends IEXMessage> clazz, final int length) {
// super("Failed to parse message. " + clazz.getSimpleName() + " requires " + length + " bytes.");
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.exception.IEXMessageException;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
|
private final int sessionID;
private final short payloadLength;
private final short messageCount;
private final long streamOffset;
private final long firstMessageSequenceNumber;
private final long sendTime;
private IEXMessageHeader(
final byte version,
final IEXMessageProtocol messageProtocolID,
final int channelID,
final int sessionID,
final short payloadLength,
final short messageCount,
final long streamOffset,
final long firstMessageSequenceNumber,
final long sendTime) {
this.version = version;
this.messageProtocolID = messageProtocolID;
this.channelID = channelID;
this.sessionID = sessionID;
this.payloadLength = payloadLength;
this.messageCount = messageCount;
this.streamOffset = streamOffset;
this.firstMessageSequenceNumber = firstMessageSequenceNumber;
this.sendTime = sendTime;
}
public static IEXMessageHeader createIEXMessageHeader(final byte[] bytes) {
if (bytes.length != LENGTH) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/exception/IEXMessageException.java
// public class IEXMessageException extends RuntimeException {
//
// public IEXMessageException(final String message) {
// super(message);
// }
//
// public IEXMessageException(final Class<? extends IEXMessage> clazz, final int length) {
// super("Failed to parse message. " + clazz.getSimpleName() + " requires " + length + " bytes.");
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessageHeader.java
import pl.zankowski.iextrading4j.hist.api.exception.IEXMessageException;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
private final int sessionID;
private final short payloadLength;
private final short messageCount;
private final long streamOffset;
private final long firstMessageSequenceNumber;
private final long sendTime;
private IEXMessageHeader(
final byte version,
final IEXMessageProtocol messageProtocolID,
final int channelID,
final int sessionID,
final short payloadLength,
final short messageCount,
final long streamOffset,
final long firstMessageSequenceNumber,
final long sendTime) {
this.version = version;
this.messageProtocolID = messageProtocolID;
this.channelID = channelID;
this.sessionID = sessionID;
this.payloadLength = payloadLength;
this.messageCount = messageCount;
this.streamOffset = streamOffset;
this.firstMessageSequenceNumber = firstMessageSequenceNumber;
this.sendTime = sendTime;
}
public static IEXMessageHeader createIEXMessageHeader(final byte[] bytes) {
if (bytes.length != LENGTH) {
|
throw new IEXMessageException("Failed to parse message. IEXMessageHeader requires 40 bytes.");
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessageHeader.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/exception/IEXMessageException.java
// public class IEXMessageException extends RuntimeException {
//
// public IEXMessageException(final String message) {
// super(message);
// }
//
// public IEXMessageException(final Class<? extends IEXMessage> clazz, final int length) {
// super("Failed to parse message. " + clazz.getSimpleName() + " requires " + length + " bytes.");
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.exception.IEXMessageException;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
|
private final long sendTime;
private IEXMessageHeader(
final byte version,
final IEXMessageProtocol messageProtocolID,
final int channelID,
final int sessionID,
final short payloadLength,
final short messageCount,
final long streamOffset,
final long firstMessageSequenceNumber,
final long sendTime) {
this.version = version;
this.messageProtocolID = messageProtocolID;
this.channelID = channelID;
this.sessionID = sessionID;
this.payloadLength = payloadLength;
this.messageCount = messageCount;
this.streamOffset = streamOffset;
this.firstMessageSequenceNumber = firstMessageSequenceNumber;
this.sendTime = sendTime;
}
public static IEXMessageHeader createIEXMessageHeader(final byte[] bytes) {
if (bytes.length != LENGTH) {
throw new IEXMessageException("Failed to parse message. IEXMessageHeader requires 40 bytes.");
}
final byte version = bytes[0];
final IEXMessageProtocol msgProtocolID = IEXMessageProtocol.getMessageProtocol(
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/exception/IEXMessageException.java
// public class IEXMessageException extends RuntimeException {
//
// public IEXMessageException(final String message) {
// super(message);
// }
//
// public IEXMessageException(final Class<? extends IEXMessage> clazz, final int length) {
// super("Failed to parse message. " + clazz.getSimpleName() + " requires " + length + " bytes.");
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessageHeader.java
import pl.zankowski.iextrading4j.hist.api.exception.IEXMessageException;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
private final long sendTime;
private IEXMessageHeader(
final byte version,
final IEXMessageProtocol messageProtocolID,
final int channelID,
final int sessionID,
final short payloadLength,
final short messageCount,
final long streamOffset,
final long firstMessageSequenceNumber,
final long sendTime) {
this.version = version;
this.messageProtocolID = messageProtocolID;
this.channelID = channelID;
this.sessionID = sessionID;
this.payloadLength = payloadLength;
this.messageCount = messageCount;
this.streamOffset = streamOffset;
this.firstMessageSequenceNumber = firstMessageSequenceNumber;
this.sendTime = sendTime;
}
public static IEXMessageHeader createIEXMessageHeader(final byte[] bytes) {
if (bytes.length != LENGTH) {
throw new IEXMessageException("Failed to parse message. IEXMessageHeader requires 40 bytes.");
}
final byte version = bytes[0];
final IEXMessageProtocol msgProtocolID = IEXMessageProtocol.getMessageProtocol(
|
IEXByteConverter.convertBytesToUnsignedShort(Arrays.copyOfRange(bytes, 2, 4)));
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/trading/field/IEXEventFlag.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.deep.trading.field;
public enum IEXEventFlag implements IEXByteEnum {
ORDER_BOOK_IS_PROCESSING_EVENT((byte) 0x0),
EVENT_PROCESSING_COMPLETE((byte) 0x1);
private static final Map<Byte, IEXEventFlag> LOOKUP = new HashMap<>();
static {
for (final IEXEventFlag value : EnumSet.allOf(IEXEventFlag.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXEventFlag(final byte code) {
this.code = code;
}
@Override
public byte getCode() {
return code;
}
public static IEXEventFlag getEventFlag(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/trading/field/IEXEventFlag.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.deep.trading.field;
public enum IEXEventFlag implements IEXByteEnum {
ORDER_BOOK_IS_PROCESSING_EVENT((byte) 0x0),
EVENT_PROCESSING_COMPLETE((byte) 0x1);
private static final Map<Byte, IEXEventFlag> LOOKUP = new HashMap<>();
static {
for (final IEXEventFlag value : EnumSet.allOf(IEXEventFlag.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXEventFlag(final byte code) {
this.code = code;
}
@Override
public byte getCode() {
return code;
}
public static IEXEventFlag getEventFlag(final byte code) {
|
return lookup(IEXEventFlag.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverterTest.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
|
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
|
byte[] bytes = IEXByteTestUtil.convertUnsignedShort(value);
assertThat(IEXByteConverter.convertBytesToUnsignedShort(bytes)).isEqualTo(value);
}
@Test
void shouldSuccessfullyConvertBytesToInt() {
final int value = 123456;
byte[] bytes = IEXByteTestUtil.convert(value);
assertThat(IEXByteConverter.convertBytesToInt(bytes)).isEqualTo(value);
}
@Test
void shouldSuccessfullyConvertIntegerToBytes() {
final byte[] bytes = IEXByteConverter.toByteArray(4);
byte[] bytes2 = IEXByteTestUtil.convert(4);
assertThat(bytes).containsExactly(bytes2);
}
@Test
void shouldSuccessfullyConvertBytesToLong() {
final long value = 1234567891L;
byte[] bytes = IEXByteTestUtil.convert(value);
assertThat(IEXByteConverter.convertBytesToLong(bytes)).isEqualTo(value);
}
@Test
void shouldSuccessfullyConvertBytesToIEXPrice() {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/field/IEXPrice.java
// public class IEXPrice implements Comparable<IEXPrice>, Serializable {
//
// private static final int SCALE = 4;
//
// private final long number;
//
// public IEXPrice(final long number) {
// this.number = number;
// }
//
// public long getNumber() {
// return number;
// }
//
// public BigDecimal toBigDecimal() {
// return BigDecimal.valueOf(number)
// .scaleByPowerOfTen(-SCALE);
// }
//
// @Override
// public int compareTo(final IEXPrice iexPrice) {
// return compare(this.getNumber(), iexPrice.getNumber());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXPrice iexPrice = (IEXPrice) o;
// return number == iexPrice.number;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(number);
// }
//
// @Override
// public String toString() {
// return toBigDecimal()
// .toString();
// }
// }
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverterTest.java
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import pl.zankowski.iextrading4j.hist.api.field.IEXPrice;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
byte[] bytes = IEXByteTestUtil.convertUnsignedShort(value);
assertThat(IEXByteConverter.convertBytesToUnsignedShort(bytes)).isEqualTo(value);
}
@Test
void shouldSuccessfullyConvertBytesToInt() {
final int value = 123456;
byte[] bytes = IEXByteTestUtil.convert(value);
assertThat(IEXByteConverter.convertBytesToInt(bytes)).isEqualTo(value);
}
@Test
void shouldSuccessfullyConvertIntegerToBytes() {
final byte[] bytes = IEXByteConverter.toByteArray(4);
byte[] bytes2 = IEXByteTestUtil.convert(4);
assertThat(bytes).containsExactly(bytes2);
}
@Test
void shouldSuccessfullyConvertBytesToLong() {
final long value = 1234567891L;
byte[] bytes = IEXByteTestUtil.convert(value);
assertThat(IEXByteConverter.convertBytesToLong(bytes)).isEqualTo(value);
}
@Test
void shouldSuccessfullyConvertBytesToIEXPrice() {
|
final IEXPrice iexPrice = new IEXPrice(123456789L);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/field/IEXSecurityEvent.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.deep.administrative.field;
public enum IEXSecurityEvent implements IEXByteEnum {
OPENING_PROCESS_COMPLETE((byte) 0x4f),
CLOSING_PROCESS_COMPLETE((byte) 0x43);
private static final Map<Byte, IEXSecurityEvent> LOOKUP = new HashMap<>();
static {
for (final IEXSecurityEvent value : EnumSet.allOf(IEXSecurityEvent.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXSecurityEvent(byte code) {
this.code = code;
}
public static IEXSecurityEvent getSecurityEvent(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/field/IEXSecurityEvent.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.deep.administrative.field;
public enum IEXSecurityEvent implements IEXByteEnum {
OPENING_PROCESS_COMPLETE((byte) 0x4f),
CLOSING_PROCESS_COMPLETE((byte) 0x43);
private static final Map<Byte, IEXSecurityEvent> LOOKUP = new HashMap<>();
static {
for (final IEXSecurityEvent value : EnumSet.allOf(IEXSecurityEvent.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXSecurityEvent(byte code) {
this.code = code;
}
public static IEXSecurityEvent getSecurityEvent(final byte code) {
|
return lookup(IEXSecurityEvent.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-test/src/test/java/pl/zankowski/iextrading4j/hist/test/message/IEXSecurityEventMessageTest.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXMessageType.java
// public enum IEXMessageType implements IEXByteEnum {
//
// QUOTE_UPDATE((byte) 0x51),
// TRADE_REPORT((byte) 0x54),
// TRADE_BREAK((byte) 0x42),
// SYSTEM_EVENT((byte) 0x53),
// SECURITY_DIRECTORY((byte) 0x44),
// TRADING_STATUS((byte) 0x48),
// OPERATIONAL_HALT_STATUS((byte) 0x4f),
// SHORT_SALE_PRICE_TEST_STATUS((byte) 0x50),
// SECURITY_EVENT((byte) 0x45),
// PRICE_LEVEL_UPDATE_BUY((byte) 0x38),
// PRICE_LEVEL_UPDATE_SELL((byte) 0x35),
// OFFICIAL_PRICE_MESSAGE((byte) 0x58),
// AUCTION_INFORMATION((byte) 0x41),
// RETAIL_LIQUIDITY_INDICATOR((byte) 0x49);
//
// private static final Map<Byte, IEXMessageType> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXMessageType value : EnumSet.allOf(IEXMessageType.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXMessageType(final byte code) {
// this.code = code;
// }
//
// public static IEXMessageType getMessageType(final byte code) {
// return lookup(IEXMessageType.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/IEXSecurityEventMessage.java
// public class IEXSecurityEventMessage extends IEXMessage {
//
// public static final int LENGTH = 18;
//
// private final IEXSecurityEvent securityEvent;
// private final long timestamp;
// private final String symbol;
//
// private IEXSecurityEventMessage(
// final IEXSecurityEvent securityEvent,
// final long timestamp,
// final String symbol) {
// super(SECURITY_EVENT);
// this.securityEvent = securityEvent;
// this.timestamp = timestamp;
// this.symbol = symbol;
// }
//
// public static IEXSecurityEventMessage createIEXMessage(final byte[] bytes) {
// final IEXSecurityEvent iexSecurityEvent = IEXSecurityEvent.getSecurityEvent(bytes[1]);
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
//
// return new IEXSecurityEventMessage(iexSecurityEvent, timestamp, symbol);
// }
//
// public IEXSecurityEvent getSecurityEvent() {
// return securityEvent;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// if (!super.equals(o)) return false;
// final IEXSecurityEventMessage that = (IEXSecurityEventMessage) o;
// return timestamp == that.timestamp &&
// securityEvent == that.securityEvent &&
// Objects.equals(symbol, that.symbol);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(super.hashCode(), securityEvent, timestamp, symbol);
// }
//
// @Override
// public String toString() {
// return "IEXSecurityEventMessage{" +
// "securityEvent=" + securityEvent +
// ", timestamp=" + timestamp +
// ", symbol='" + symbol + '\'' +
// "} " + super.toString();
// }
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/field/IEXSecurityEvent.java
// public enum IEXSecurityEvent implements IEXByteEnum {
//
// OPENING_PROCESS_COMPLETE((byte) 0x4f),
// CLOSING_PROCESS_COMPLETE((byte) 0x43);
//
// private static final Map<Byte, IEXSecurityEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSecurityEvent value : EnumSet.allOf(IEXSecurityEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSecurityEvent(byte code) {
// this.code = code;
// }
//
// public static IEXSecurityEvent getSecurityEvent(final byte code) {
// return lookup(IEXSecurityEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-test/src/test/java/pl/zankowski/iextrading4j/hist/test/ExtendedUnitTestBase.java
// public abstract class ExtendedUnitTestBase {
//
// protected byte[] loadPacket(final String fileName) throws IOException {
// return ByteStreams.toByteArray(ExtendedUnitTestBase.class.getClassLoader().getResourceAsStream(fileName));
// }
//
// }
|
import org.junit.jupiter.api.Test;
import pl.zankowski.iextrading4j.hist.api.IEXMessageType;
import pl.zankowski.iextrading4j.hist.deep.administrative.IEXSecurityEventMessage;
import pl.zankowski.iextrading4j.hist.deep.administrative.field.IEXSecurityEvent;
import pl.zankowski.iextrading4j.hist.test.ExtendedUnitTestBase;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
|
package pl.zankowski.iextrading4j.hist.test.message;
class IEXSecurityEventMessageTest extends ExtendedUnitTestBase {
@Test
void testSecurityEventMessage() throws IOException {
final byte[] bytes = loadPacket("IEXSecurityEventMessage.dump");
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXMessageType.java
// public enum IEXMessageType implements IEXByteEnum {
//
// QUOTE_UPDATE((byte) 0x51),
// TRADE_REPORT((byte) 0x54),
// TRADE_BREAK((byte) 0x42),
// SYSTEM_EVENT((byte) 0x53),
// SECURITY_DIRECTORY((byte) 0x44),
// TRADING_STATUS((byte) 0x48),
// OPERATIONAL_HALT_STATUS((byte) 0x4f),
// SHORT_SALE_PRICE_TEST_STATUS((byte) 0x50),
// SECURITY_EVENT((byte) 0x45),
// PRICE_LEVEL_UPDATE_BUY((byte) 0x38),
// PRICE_LEVEL_UPDATE_SELL((byte) 0x35),
// OFFICIAL_PRICE_MESSAGE((byte) 0x58),
// AUCTION_INFORMATION((byte) 0x41),
// RETAIL_LIQUIDITY_INDICATOR((byte) 0x49);
//
// private static final Map<Byte, IEXMessageType> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXMessageType value : EnumSet.allOf(IEXMessageType.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXMessageType(final byte code) {
// this.code = code;
// }
//
// public static IEXMessageType getMessageType(final byte code) {
// return lookup(IEXMessageType.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/IEXSecurityEventMessage.java
// public class IEXSecurityEventMessage extends IEXMessage {
//
// public static final int LENGTH = 18;
//
// private final IEXSecurityEvent securityEvent;
// private final long timestamp;
// private final String symbol;
//
// private IEXSecurityEventMessage(
// final IEXSecurityEvent securityEvent,
// final long timestamp,
// final String symbol) {
// super(SECURITY_EVENT);
// this.securityEvent = securityEvent;
// this.timestamp = timestamp;
// this.symbol = symbol;
// }
//
// public static IEXSecurityEventMessage createIEXMessage(final byte[] bytes) {
// final IEXSecurityEvent iexSecurityEvent = IEXSecurityEvent.getSecurityEvent(bytes[1]);
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
//
// return new IEXSecurityEventMessage(iexSecurityEvent, timestamp, symbol);
// }
//
// public IEXSecurityEvent getSecurityEvent() {
// return securityEvent;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// if (!super.equals(o)) return false;
// final IEXSecurityEventMessage that = (IEXSecurityEventMessage) o;
// return timestamp == that.timestamp &&
// securityEvent == that.securityEvent &&
// Objects.equals(symbol, that.symbol);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(super.hashCode(), securityEvent, timestamp, symbol);
// }
//
// @Override
// public String toString() {
// return "IEXSecurityEventMessage{" +
// "securityEvent=" + securityEvent +
// ", timestamp=" + timestamp +
// ", symbol='" + symbol + '\'' +
// "} " + super.toString();
// }
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/field/IEXSecurityEvent.java
// public enum IEXSecurityEvent implements IEXByteEnum {
//
// OPENING_PROCESS_COMPLETE((byte) 0x4f),
// CLOSING_PROCESS_COMPLETE((byte) 0x43);
//
// private static final Map<Byte, IEXSecurityEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSecurityEvent value : EnumSet.allOf(IEXSecurityEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSecurityEvent(byte code) {
// this.code = code;
// }
//
// public static IEXSecurityEvent getSecurityEvent(final byte code) {
// return lookup(IEXSecurityEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-test/src/test/java/pl/zankowski/iextrading4j/hist/test/ExtendedUnitTestBase.java
// public abstract class ExtendedUnitTestBase {
//
// protected byte[] loadPacket(final String fileName) throws IOException {
// return ByteStreams.toByteArray(ExtendedUnitTestBase.class.getClassLoader().getResourceAsStream(fileName));
// }
//
// }
// Path: iextrading4j-hist-test/src/test/java/pl/zankowski/iextrading4j/hist/test/message/IEXSecurityEventMessageTest.java
import org.junit.jupiter.api.Test;
import pl.zankowski.iextrading4j.hist.api.IEXMessageType;
import pl.zankowski.iextrading4j.hist.deep.administrative.IEXSecurityEventMessage;
import pl.zankowski.iextrading4j.hist.deep.administrative.field.IEXSecurityEvent;
import pl.zankowski.iextrading4j.hist.test.ExtendedUnitTestBase;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
package pl.zankowski.iextrading4j.hist.test.message;
class IEXSecurityEventMessageTest extends ExtendedUnitTestBase {
@Test
void testSecurityEventMessage() throws IOException {
final byte[] bytes = loadPacket("IEXSecurityEventMessage.dump");
|
final IEXSecurityEventMessage message = IEXSecurityEventMessage.createIEXMessage(bytes);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-test/src/test/java/pl/zankowski/iextrading4j/hist/test/message/IEXSecurityEventMessageTest.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXMessageType.java
// public enum IEXMessageType implements IEXByteEnum {
//
// QUOTE_UPDATE((byte) 0x51),
// TRADE_REPORT((byte) 0x54),
// TRADE_BREAK((byte) 0x42),
// SYSTEM_EVENT((byte) 0x53),
// SECURITY_DIRECTORY((byte) 0x44),
// TRADING_STATUS((byte) 0x48),
// OPERATIONAL_HALT_STATUS((byte) 0x4f),
// SHORT_SALE_PRICE_TEST_STATUS((byte) 0x50),
// SECURITY_EVENT((byte) 0x45),
// PRICE_LEVEL_UPDATE_BUY((byte) 0x38),
// PRICE_LEVEL_UPDATE_SELL((byte) 0x35),
// OFFICIAL_PRICE_MESSAGE((byte) 0x58),
// AUCTION_INFORMATION((byte) 0x41),
// RETAIL_LIQUIDITY_INDICATOR((byte) 0x49);
//
// private static final Map<Byte, IEXMessageType> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXMessageType value : EnumSet.allOf(IEXMessageType.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXMessageType(final byte code) {
// this.code = code;
// }
//
// public static IEXMessageType getMessageType(final byte code) {
// return lookup(IEXMessageType.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/IEXSecurityEventMessage.java
// public class IEXSecurityEventMessage extends IEXMessage {
//
// public static final int LENGTH = 18;
//
// private final IEXSecurityEvent securityEvent;
// private final long timestamp;
// private final String symbol;
//
// private IEXSecurityEventMessage(
// final IEXSecurityEvent securityEvent,
// final long timestamp,
// final String symbol) {
// super(SECURITY_EVENT);
// this.securityEvent = securityEvent;
// this.timestamp = timestamp;
// this.symbol = symbol;
// }
//
// public static IEXSecurityEventMessage createIEXMessage(final byte[] bytes) {
// final IEXSecurityEvent iexSecurityEvent = IEXSecurityEvent.getSecurityEvent(bytes[1]);
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
//
// return new IEXSecurityEventMessage(iexSecurityEvent, timestamp, symbol);
// }
//
// public IEXSecurityEvent getSecurityEvent() {
// return securityEvent;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// if (!super.equals(o)) return false;
// final IEXSecurityEventMessage that = (IEXSecurityEventMessage) o;
// return timestamp == that.timestamp &&
// securityEvent == that.securityEvent &&
// Objects.equals(symbol, that.symbol);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(super.hashCode(), securityEvent, timestamp, symbol);
// }
//
// @Override
// public String toString() {
// return "IEXSecurityEventMessage{" +
// "securityEvent=" + securityEvent +
// ", timestamp=" + timestamp +
// ", symbol='" + symbol + '\'' +
// "} " + super.toString();
// }
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/field/IEXSecurityEvent.java
// public enum IEXSecurityEvent implements IEXByteEnum {
//
// OPENING_PROCESS_COMPLETE((byte) 0x4f),
// CLOSING_PROCESS_COMPLETE((byte) 0x43);
//
// private static final Map<Byte, IEXSecurityEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSecurityEvent value : EnumSet.allOf(IEXSecurityEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSecurityEvent(byte code) {
// this.code = code;
// }
//
// public static IEXSecurityEvent getSecurityEvent(final byte code) {
// return lookup(IEXSecurityEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-test/src/test/java/pl/zankowski/iextrading4j/hist/test/ExtendedUnitTestBase.java
// public abstract class ExtendedUnitTestBase {
//
// protected byte[] loadPacket(final String fileName) throws IOException {
// return ByteStreams.toByteArray(ExtendedUnitTestBase.class.getClassLoader().getResourceAsStream(fileName));
// }
//
// }
|
import org.junit.jupiter.api.Test;
import pl.zankowski.iextrading4j.hist.api.IEXMessageType;
import pl.zankowski.iextrading4j.hist.deep.administrative.IEXSecurityEventMessage;
import pl.zankowski.iextrading4j.hist.deep.administrative.field.IEXSecurityEvent;
import pl.zankowski.iextrading4j.hist.test.ExtendedUnitTestBase;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
|
package pl.zankowski.iextrading4j.hist.test.message;
class IEXSecurityEventMessageTest extends ExtendedUnitTestBase {
@Test
void testSecurityEventMessage() throws IOException {
final byte[] bytes = loadPacket("IEXSecurityEventMessage.dump");
final IEXSecurityEventMessage message = IEXSecurityEventMessage.createIEXMessage(bytes);
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXMessageType.java
// public enum IEXMessageType implements IEXByteEnum {
//
// QUOTE_UPDATE((byte) 0x51),
// TRADE_REPORT((byte) 0x54),
// TRADE_BREAK((byte) 0x42),
// SYSTEM_EVENT((byte) 0x53),
// SECURITY_DIRECTORY((byte) 0x44),
// TRADING_STATUS((byte) 0x48),
// OPERATIONAL_HALT_STATUS((byte) 0x4f),
// SHORT_SALE_PRICE_TEST_STATUS((byte) 0x50),
// SECURITY_EVENT((byte) 0x45),
// PRICE_LEVEL_UPDATE_BUY((byte) 0x38),
// PRICE_LEVEL_UPDATE_SELL((byte) 0x35),
// OFFICIAL_PRICE_MESSAGE((byte) 0x58),
// AUCTION_INFORMATION((byte) 0x41),
// RETAIL_LIQUIDITY_INDICATOR((byte) 0x49);
//
// private static final Map<Byte, IEXMessageType> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXMessageType value : EnumSet.allOf(IEXMessageType.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXMessageType(final byte code) {
// this.code = code;
// }
//
// public static IEXMessageType getMessageType(final byte code) {
// return lookup(IEXMessageType.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/IEXSecurityEventMessage.java
// public class IEXSecurityEventMessage extends IEXMessage {
//
// public static final int LENGTH = 18;
//
// private final IEXSecurityEvent securityEvent;
// private final long timestamp;
// private final String symbol;
//
// private IEXSecurityEventMessage(
// final IEXSecurityEvent securityEvent,
// final long timestamp,
// final String symbol) {
// super(SECURITY_EVENT);
// this.securityEvent = securityEvent;
// this.timestamp = timestamp;
// this.symbol = symbol;
// }
//
// public static IEXSecurityEventMessage createIEXMessage(final byte[] bytes) {
// final IEXSecurityEvent iexSecurityEvent = IEXSecurityEvent.getSecurityEvent(bytes[1]);
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
//
// return new IEXSecurityEventMessage(iexSecurityEvent, timestamp, symbol);
// }
//
// public IEXSecurityEvent getSecurityEvent() {
// return securityEvent;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// if (!super.equals(o)) return false;
// final IEXSecurityEventMessage that = (IEXSecurityEventMessage) o;
// return timestamp == that.timestamp &&
// securityEvent == that.securityEvent &&
// Objects.equals(symbol, that.symbol);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(super.hashCode(), securityEvent, timestamp, symbol);
// }
//
// @Override
// public String toString() {
// return "IEXSecurityEventMessage{" +
// "securityEvent=" + securityEvent +
// ", timestamp=" + timestamp +
// ", symbol='" + symbol + '\'' +
// "} " + super.toString();
// }
// }
//
// Path: iextrading4j-hist-deep/src/main/java/pl/zankowski/iextrading4j/hist/deep/administrative/field/IEXSecurityEvent.java
// public enum IEXSecurityEvent implements IEXByteEnum {
//
// OPENING_PROCESS_COMPLETE((byte) 0x4f),
// CLOSING_PROCESS_COMPLETE((byte) 0x43);
//
// private static final Map<Byte, IEXSecurityEvent> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXSecurityEvent value : EnumSet.allOf(IEXSecurityEvent.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXSecurityEvent(byte code) {
// this.code = code;
// }
//
// public static IEXSecurityEvent getSecurityEvent(final byte code) {
// return lookup(IEXSecurityEvent.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-test/src/test/java/pl/zankowski/iextrading4j/hist/test/ExtendedUnitTestBase.java
// public abstract class ExtendedUnitTestBase {
//
// protected byte[] loadPacket(final String fileName) throws IOException {
// return ByteStreams.toByteArray(ExtendedUnitTestBase.class.getClassLoader().getResourceAsStream(fileName));
// }
//
// }
// Path: iextrading4j-hist-test/src/test/java/pl/zankowski/iextrading4j/hist/test/message/IEXSecurityEventMessageTest.java
import org.junit.jupiter.api.Test;
import pl.zankowski.iextrading4j.hist.api.IEXMessageType;
import pl.zankowski.iextrading4j.hist.deep.administrative.IEXSecurityEventMessage;
import pl.zankowski.iextrading4j.hist.deep.administrative.field.IEXSecurityEvent;
import pl.zankowski.iextrading4j.hist.test.ExtendedUnitTestBase;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
package pl.zankowski.iextrading4j.hist.test.message;
class IEXSecurityEventMessageTest extends ExtendedUnitTestBase {
@Test
void testSecurityEventMessage() throws IOException {
final byte[] bytes = loadPacket("IEXSecurityEventMessage.dump");
final IEXSecurityEventMessage message = IEXSecurityEventMessage.createIEXMessage(bytes);
|
assertThat(message.getMessageType()).isEqualTo(IEXMessageType.SECURITY_EVENT);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXMessageType.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.api;
public enum IEXMessageType implements IEXByteEnum {
QUOTE_UPDATE((byte) 0x51),
TRADE_REPORT((byte) 0x54),
TRADE_BREAK((byte) 0x42),
SYSTEM_EVENT((byte) 0x53),
SECURITY_DIRECTORY((byte) 0x44),
TRADING_STATUS((byte) 0x48),
OPERATIONAL_HALT_STATUS((byte) 0x4f),
SHORT_SALE_PRICE_TEST_STATUS((byte) 0x50),
SECURITY_EVENT((byte) 0x45),
PRICE_LEVEL_UPDATE_BUY((byte) 0x38),
PRICE_LEVEL_UPDATE_SELL((byte) 0x35),
OFFICIAL_PRICE_MESSAGE((byte) 0x58),
AUCTION_INFORMATION((byte) 0x41),
RETAIL_LIQUIDITY_INDICATOR((byte) 0x49);
private static final Map<Byte, IEXMessageType> LOOKUP = new HashMap<>();
static {
for (final IEXMessageType value : EnumSet.allOf(IEXMessageType.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXMessageType(final byte code) {
this.code = code;
}
public static IEXMessageType getMessageType(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXMessageType.java
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.api;
public enum IEXMessageType implements IEXByteEnum {
QUOTE_UPDATE((byte) 0x51),
TRADE_REPORT((byte) 0x54),
TRADE_BREAK((byte) 0x42),
SYSTEM_EVENT((byte) 0x53),
SECURITY_DIRECTORY((byte) 0x44),
TRADING_STATUS((byte) 0x48),
OPERATIONAL_HALT_STATUS((byte) 0x4f),
SHORT_SALE_PRICE_TEST_STATUS((byte) 0x50),
SECURITY_EVENT((byte) 0x45),
PRICE_LEVEL_UPDATE_BUY((byte) 0x38),
PRICE_LEVEL_UPDATE_SELL((byte) 0x35),
OFFICIAL_PRICE_MESSAGE((byte) 0x58),
AUCTION_INFORMATION((byte) 0x41),
RETAIL_LIQUIDITY_INDICATOR((byte) 0x49);
private static final Map<Byte, IEXMessageType> LOOKUP = new HashMap<>();
static {
for (final IEXMessageType value : EnumSet.allOf(IEXMessageType.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXMessageType(final byte code) {
this.code = code;
}
public static IEXMessageType getMessageType(final byte code) {
|
return lookup(IEXMessageType.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXRetailLiquidityIndicator.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXRetailLiquidityIndicator implements IEXByteEnum {
NOT_APPLICABLE((byte) 0x20),
BUY_INTEREST((byte) 0x41),
SELL_INTEREST((byte) 0x42),
BUY_AND_SELL_INTEREST((byte) 0x43);
private static final Map<Byte, IEXRetailLiquidityIndicator> LOOKUP = new HashMap<>();
static {
for (final IEXRetailLiquidityIndicator value : EnumSet.allOf(IEXRetailLiquidityIndicator.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXRetailLiquidityIndicator(final byte code) {
this.code = code;
}
public static IEXRetailLiquidityIndicator getRetailLiquidityIndicator(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXRetailLiquidityIndicator.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXRetailLiquidityIndicator implements IEXByteEnum {
NOT_APPLICABLE((byte) 0x20),
BUY_INTEREST((byte) 0x41),
SELL_INTEREST((byte) 0x42),
BUY_AND_SELL_INTEREST((byte) 0x43);
private static final Map<Byte, IEXRetailLiquidityIndicator> LOOKUP = new HashMap<>();
static {
for (final IEXRetailLiquidityIndicator value : EnumSet.allOf(IEXRetailLiquidityIndicator.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXRetailLiquidityIndicator(final byte code) {
this.code = code;
}
public static IEXRetailLiquidityIndicator getRetailLiquidityIndicator(final byte code) {
|
return lookup(IEXRetailLiquidityIndicator.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXTradingStatusMessage.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXTradingStatus.java
// public enum IEXTradingStatus implements IEXByteEnum {
//
// TRADING_HALTED((byte) 0x48),
// ORDER_ACCEPTANCE_PERIOD((byte) 0x4f),
// ORDER_ACCEPTANCE_PERIOD_ON_IEX((byte) 0x50),
// TRADING_ON_IEX((byte) 0x54);
//
// private static final Map<Byte, IEXTradingStatus> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXTradingStatus value : EnumSet.allOf(IEXTradingStatus.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXTradingStatus(final byte code) {
// this.code = code;
// }
//
// public static IEXTradingStatus getTradingStatus(final byte code) {
// return lookup(IEXTradingStatus.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXTradingStatus;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.TRADING_STATUS;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXTradingStatusMessage extends IEXMessage {
public static final int LENGTH = 22;
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXTradingStatus.java
// public enum IEXTradingStatus implements IEXByteEnum {
//
// TRADING_HALTED((byte) 0x48),
// ORDER_ACCEPTANCE_PERIOD((byte) 0x4f),
// ORDER_ACCEPTANCE_PERIOD_ON_IEX((byte) 0x50),
// TRADING_ON_IEX((byte) 0x54);
//
// private static final Map<Byte, IEXTradingStatus> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXTradingStatus value : EnumSet.allOf(IEXTradingStatus.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXTradingStatus(final byte code) {
// this.code = code;
// }
//
// public static IEXTradingStatus getTradingStatus(final byte code) {
// return lookup(IEXTradingStatus.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXTradingStatusMessage.java
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXTradingStatus;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.TRADING_STATUS;
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXTradingStatusMessage extends IEXMessage {
public static final int LENGTH = 22;
|
private final IEXTradingStatus tradingStatus;
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXTradingStatusMessage.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXTradingStatus.java
// public enum IEXTradingStatus implements IEXByteEnum {
//
// TRADING_HALTED((byte) 0x48),
// ORDER_ACCEPTANCE_PERIOD((byte) 0x4f),
// ORDER_ACCEPTANCE_PERIOD_ON_IEX((byte) 0x50),
// TRADING_ON_IEX((byte) 0x54);
//
// private static final Map<Byte, IEXTradingStatus> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXTradingStatus value : EnumSet.allOf(IEXTradingStatus.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXTradingStatus(final byte code) {
// this.code = code;
// }
//
// public static IEXTradingStatus getTradingStatus(final byte code) {
// return lookup(IEXTradingStatus.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXTradingStatus;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.TRADING_STATUS;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXTradingStatusMessage extends IEXMessage {
public static final int LENGTH = 22;
private final IEXTradingStatus tradingStatus;
private final long timestamp;
private final String symbol;
private final String reason;
private IEXTradingStatusMessage(
final IEXTradingStatus tradingStatus,
final long timestamp,
final String symbol,
final String reason) {
super(TRADING_STATUS);
this.tradingStatus = tradingStatus;
this.timestamp = timestamp;
this.symbol = symbol;
this.reason = reason;
}
public static IEXTradingStatusMessage createIEXMessage(final byte[] bytes) {
final IEXTradingStatus tradingStatus = IEXTradingStatus.getTradingStatus(bytes[1]);
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXTradingStatus.java
// public enum IEXTradingStatus implements IEXByteEnum {
//
// TRADING_HALTED((byte) 0x48),
// ORDER_ACCEPTANCE_PERIOD((byte) 0x4f),
// ORDER_ACCEPTANCE_PERIOD_ON_IEX((byte) 0x50),
// TRADING_ON_IEX((byte) 0x54);
//
// private static final Map<Byte, IEXTradingStatus> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXTradingStatus value : EnumSet.allOf(IEXTradingStatus.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXTradingStatus(final byte code) {
// this.code = code;
// }
//
// public static IEXTradingStatus getTradingStatus(final byte code) {
// return lookup(IEXTradingStatus.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXTradingStatusMessage.java
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXTradingStatus;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.TRADING_STATUS;
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXTradingStatusMessage extends IEXMessage {
public static final int LENGTH = 22;
private final IEXTradingStatus tradingStatus;
private final long timestamp;
private final String symbol;
private final String reason;
private IEXTradingStatusMessage(
final IEXTradingStatus tradingStatus,
final long timestamp,
final String symbol,
final String reason) {
super(TRADING_STATUS);
this.tradingStatus = tradingStatus;
this.timestamp = timestamp;
this.symbol = symbol;
this.reason = reason;
}
public static IEXTradingStatusMessage createIEXMessage(final byte[] bytes) {
final IEXTradingStatus tradingStatus = IEXTradingStatus.getTradingStatus(bytes[1]);
|
final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/auction/field/IEXAuctionType.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.api.message.auction.field;
public enum IEXAuctionType implements IEXByteEnum {
OPENING_AUCTION((byte) 0x4f),
CLOSING_AUCTION((byte) 0x43),
IPO_AUCTION((byte) 0x49),
HALT_AUCTION((byte) 0x48),
VOLATILITY_AUCTION((byte) 0x56);
private static final Map<Byte, IEXAuctionType> LOOKUP = new HashMap<>();
static {
for (final IEXAuctionType value : EnumSet.allOf(IEXAuctionType.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXAuctionType(final byte code) {
this.code = code;
}
public static IEXAuctionType getAuctionType(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/auction/field/IEXAuctionType.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.api.message.auction.field;
public enum IEXAuctionType implements IEXByteEnum {
OPENING_AUCTION((byte) 0x4f),
CLOSING_AUCTION((byte) 0x43),
IPO_AUCTION((byte) 0x49),
HALT_AUCTION((byte) 0x48),
VOLATILITY_AUCTION((byte) 0x56);
private static final Map<Byte, IEXAuctionType> LOOKUP = new HashMap<>();
static {
for (final IEXAuctionType value : EnumSet.allOf(IEXAuctionType.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXAuctionType(final byte code) {
this.code = code;
}
public static IEXAuctionType getAuctionType(final byte code) {
|
return lookup(IEXAuctionType.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXShortSalePriceTestStatus.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
|
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXShortSalePriceTestStatus implements IEXByteEnum {
PRICE_TEST_NOT_IN_EFFECT((byte) 0x0),
PRICE_TEST_IN_EFFECT((byte) 0x1);
private static final Map<Byte, IEXShortSalePriceTestStatus> LOOKUP = new HashMap<>();
static {
for (final IEXShortSalePriceTestStatus value : EnumSet.allOf(IEXShortSalePriceTestStatus.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXShortSalePriceTestStatus(final byte code) {
this.code = code;
}
public static IEXShortSalePriceTestStatus getShortSalePriceTestStatus(final byte code) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/IEXByteEnum.java
// public interface IEXByteEnum {
//
// byte getCode();
//
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteEnumLookupUtil.java
// public static <E extends Enum<E> & IEXByteEnum> E lookup(final Class<E> clazz, final Map<Byte, E> lookup,
// byte code) {
// final E value = lookup.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum " + clazz.getSimpleName());
// }
// return value;
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXShortSalePriceTestStatus.java
import pl.zankowski.iextrading4j.hist.api.IEXByteEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static pl.zankowski.iextrading4j.hist.api.util.IEXByteEnumLookupUtil.lookup;
package pl.zankowski.iextrading4j.hist.api.message.administrative.field;
public enum IEXShortSalePriceTestStatus implements IEXByteEnum {
PRICE_TEST_NOT_IN_EFFECT((byte) 0x0),
PRICE_TEST_IN_EFFECT((byte) 0x1);
private static final Map<Byte, IEXShortSalePriceTestStatus> LOOKUP = new HashMap<>();
static {
for (final IEXShortSalePriceTestStatus value : EnumSet.allOf(IEXShortSalePriceTestStatus.class))
LOOKUP.put(value.getCode(), value);
}
private final byte code;
IEXShortSalePriceTestStatus(final byte code) {
this.code = code;
}
public static IEXShortSalePriceTestStatus getShortSalePriceTestStatus(final byte code) {
|
return lookup(IEXShortSalePriceTestStatus.class, LOOKUP, code);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/IEXMessageProtocolTest.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessageProtocol.java
// public enum IEXMessageProtocol {
//
// TOPS_1_5(0x8002),
// TOPS_1_6(0x8003),
// DEEP(0x8004);
//
// private static final Map<Integer, IEXMessageProtocol> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXMessageProtocol value : EnumSet.allOf(IEXMessageProtocol.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final int code;
//
// IEXMessageProtocol(final int code) {
// this.code = code;
// }
//
// public int getCode() {
// return code;
// }
//
// public static IEXMessageProtocol getMessageProtocol(final int code) {
// final IEXMessageProtocol value = LOOKUP.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum IEXMessageProtocol");
// }
// return value;
// }
// }
|
import org.junit.jupiter.api.Test;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessageProtocol;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
|
package pl.zankowski.iextrading4j.hist.api;
class IEXMessageProtocolTest {
@Test
void shouldSuccessfullyFindEnumBasedOnCode() {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessageProtocol.java
// public enum IEXMessageProtocol {
//
// TOPS_1_5(0x8002),
// TOPS_1_6(0x8003),
// DEEP(0x8004);
//
// private static final Map<Integer, IEXMessageProtocol> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXMessageProtocol value : EnumSet.allOf(IEXMessageProtocol.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final int code;
//
// IEXMessageProtocol(final int code) {
// this.code = code;
// }
//
// public int getCode() {
// return code;
// }
//
// public static IEXMessageProtocol getMessageProtocol(final int code) {
// final IEXMessageProtocol value = LOOKUP.get(code);
// if (value == null) {
// throw new IllegalArgumentException("Unknown value: " + code + " for enum IEXMessageProtocol");
// }
// return value;
// }
// }
// Path: iextrading4j-hist-api/src/test/java/pl/zankowski/iextrading4j/hist/api/IEXMessageProtocolTest.java
import org.junit.jupiter.api.Test;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessageProtocol;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
package pl.zankowski.iextrading4j.hist.api;
class IEXMessageProtocolTest {
@Test
void shouldSuccessfullyFindEnumBasedOnCode() {
|
final IEXMessageProtocol value = IEXMessageProtocol.TOPS_1_6;
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/BigSegmentBenchmark.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXSegment.java
// public abstract class IEXSegment {
//
// private final IEXMessageHeader messageHeader;
// private final List<IEXMessage> messages;
//
// protected IEXSegment(
// final IEXMessageHeader messageHeader,
// final List<IEXMessage> messages) {
// this.messageHeader = messageHeader;
// this.messages = new ArrayList<>(messages);
// }
//
// public IEXMessageHeader getMessageHeader() {
// return messageHeader;
// }
//
// public List<IEXMessage> getMessages() {
// return new ArrayList<>(messages);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXSegment that = (IEXSegment) o;
// return Objects.equals(messageHeader, that.messageHeader) &&
// Objects.equals(messages, that.messages);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageHeader, messages);
// }
//
// @Override
// public String toString() {
// return "IEXSegment{" +
// "messageHeader=" + messageHeader +
// ", messages=" + messages +
// '}';
// }
// }
//
// Path: iextrading4j-hist-tops/src/main/java/pl/zankowski/iextrading4j/hist/tops/IEXTOPSMessageBlock.java
// public static IEXSegment createIEXSegment(final byte[] packet) {
// final List<IEXMessage> iexMessages = new ArrayList<>();
// int offset = 40;
//
// final IEXMessageHeader iexMessageHeader = IEXMessageHeader.createIEXMessageHeader(Arrays.copyOfRange(packet, 0, offset));
//
// for (int i = 0; i < iexMessageHeader.getMessageCount(); i++) {
// short length = IEXByteConverter.convertBytesToShort(Arrays.copyOfRange(packet, offset, offset = offset + 2));
// iexMessages.add(resolveMessage(Arrays.copyOfRange(packet, offset, offset = offset + length)));
// }
//
// return new IEXTOPSMessageBlock(iexMessageHeader, iexMessages);
// }
|
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXSegment;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.tops.IEXTOPSMessageBlock.createIEXSegment;
|
package pl.zankowski.iextrading4j.hist.perf;
public class BigSegmentBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("BigTopsSegment.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXSegment.java
// public abstract class IEXSegment {
//
// private final IEXMessageHeader messageHeader;
// private final List<IEXMessage> messages;
//
// protected IEXSegment(
// final IEXMessageHeader messageHeader,
// final List<IEXMessage> messages) {
// this.messageHeader = messageHeader;
// this.messages = new ArrayList<>(messages);
// }
//
// public IEXMessageHeader getMessageHeader() {
// return messageHeader;
// }
//
// public List<IEXMessage> getMessages() {
// return new ArrayList<>(messages);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXSegment that = (IEXSegment) o;
// return Objects.equals(messageHeader, that.messageHeader) &&
// Objects.equals(messages, that.messages);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageHeader, messages);
// }
//
// @Override
// public String toString() {
// return "IEXSegment{" +
// "messageHeader=" + messageHeader +
// ", messages=" + messages +
// '}';
// }
// }
//
// Path: iextrading4j-hist-tops/src/main/java/pl/zankowski/iextrading4j/hist/tops/IEXTOPSMessageBlock.java
// public static IEXSegment createIEXSegment(final byte[] packet) {
// final List<IEXMessage> iexMessages = new ArrayList<>();
// int offset = 40;
//
// final IEXMessageHeader iexMessageHeader = IEXMessageHeader.createIEXMessageHeader(Arrays.copyOfRange(packet, 0, offset));
//
// for (int i = 0; i < iexMessageHeader.getMessageCount(); i++) {
// short length = IEXByteConverter.convertBytesToShort(Arrays.copyOfRange(packet, offset, offset = offset + 2));
// iexMessages.add(resolveMessage(Arrays.copyOfRange(packet, offset, offset = offset + length)));
// }
//
// return new IEXTOPSMessageBlock(iexMessageHeader, iexMessages);
// }
// Path: iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/BigSegmentBenchmark.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXSegment;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.tops.IEXTOPSMessageBlock.createIEXSegment;
package pl.zankowski.iextrading4j.hist.perf;
public class BigSegmentBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("BigTopsSegment.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
public IEXSegment bigSegmentBenchmark(final BenchmarkState benchmarkState) {
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/BigSegmentBenchmark.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXSegment.java
// public abstract class IEXSegment {
//
// private final IEXMessageHeader messageHeader;
// private final List<IEXMessage> messages;
//
// protected IEXSegment(
// final IEXMessageHeader messageHeader,
// final List<IEXMessage> messages) {
// this.messageHeader = messageHeader;
// this.messages = new ArrayList<>(messages);
// }
//
// public IEXMessageHeader getMessageHeader() {
// return messageHeader;
// }
//
// public List<IEXMessage> getMessages() {
// return new ArrayList<>(messages);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXSegment that = (IEXSegment) o;
// return Objects.equals(messageHeader, that.messageHeader) &&
// Objects.equals(messages, that.messages);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageHeader, messages);
// }
//
// @Override
// public String toString() {
// return "IEXSegment{" +
// "messageHeader=" + messageHeader +
// ", messages=" + messages +
// '}';
// }
// }
//
// Path: iextrading4j-hist-tops/src/main/java/pl/zankowski/iextrading4j/hist/tops/IEXTOPSMessageBlock.java
// public static IEXSegment createIEXSegment(final byte[] packet) {
// final List<IEXMessage> iexMessages = new ArrayList<>();
// int offset = 40;
//
// final IEXMessageHeader iexMessageHeader = IEXMessageHeader.createIEXMessageHeader(Arrays.copyOfRange(packet, 0, offset));
//
// for (int i = 0; i < iexMessageHeader.getMessageCount(); i++) {
// short length = IEXByteConverter.convertBytesToShort(Arrays.copyOfRange(packet, offset, offset = offset + 2));
// iexMessages.add(resolveMessage(Arrays.copyOfRange(packet, offset, offset = offset + length)));
// }
//
// return new IEXTOPSMessageBlock(iexMessageHeader, iexMessages);
// }
|
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXSegment;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.tops.IEXTOPSMessageBlock.createIEXSegment;
|
package pl.zankowski.iextrading4j.hist.perf;
public class BigSegmentBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("BigTopsSegment.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public IEXSegment bigSegmentBenchmark(final BenchmarkState benchmarkState) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXSegment.java
// public abstract class IEXSegment {
//
// private final IEXMessageHeader messageHeader;
// private final List<IEXMessage> messages;
//
// protected IEXSegment(
// final IEXMessageHeader messageHeader,
// final List<IEXMessage> messages) {
// this.messageHeader = messageHeader;
// this.messages = new ArrayList<>(messages);
// }
//
// public IEXMessageHeader getMessageHeader() {
// return messageHeader;
// }
//
// public List<IEXMessage> getMessages() {
// return new ArrayList<>(messages);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// IEXSegment that = (IEXSegment) o;
// return Objects.equals(messageHeader, that.messageHeader) &&
// Objects.equals(messages, that.messages);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageHeader, messages);
// }
//
// @Override
// public String toString() {
// return "IEXSegment{" +
// "messageHeader=" + messageHeader +
// ", messages=" + messages +
// '}';
// }
// }
//
// Path: iextrading4j-hist-tops/src/main/java/pl/zankowski/iextrading4j/hist/tops/IEXTOPSMessageBlock.java
// public static IEXSegment createIEXSegment(final byte[] packet) {
// final List<IEXMessage> iexMessages = new ArrayList<>();
// int offset = 40;
//
// final IEXMessageHeader iexMessageHeader = IEXMessageHeader.createIEXMessageHeader(Arrays.copyOfRange(packet, 0, offset));
//
// for (int i = 0; i < iexMessageHeader.getMessageCount(); i++) {
// short length = IEXByteConverter.convertBytesToShort(Arrays.copyOfRange(packet, offset, offset = offset + 2));
// iexMessages.add(resolveMessage(Arrays.copyOfRange(packet, offset, offset = offset + length)));
// }
//
// return new IEXTOPSMessageBlock(iexMessageHeader, iexMessages);
// }
// Path: iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/BigSegmentBenchmark.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXSegment;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.tops.IEXTOPSMessageBlock.createIEXSegment;
package pl.zankowski.iextrading4j.hist.perf;
public class BigSegmentBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("BigTopsSegment.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public IEXSegment bigSegmentBenchmark(final BenchmarkState benchmarkState) {
|
return createIEXSegment(benchmarkState.packet);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/LotsOfEnumsBenchmark.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXSecurityDirectoryMessage.java
// public static IEXSecurityDirectoryMessage createIEXMessage(final byte[] bytes) {
// final byte iexSecurityDirectoryFlag = bytes[1];
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
// final int roundLotSize = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 18, 22));
// final IEXPrice adjustedPOCPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 22, 30));
// final IEXLULDTier iexluldTier = IEXLULDTier.getLULDTier(bytes[30]);
//
// return new IEXSecurityDirectoryMessage(iexSecurityDirectoryFlag, timestamp, symbol, roundLotSize,
// adjustedPOCPrice, iexluldTier);
// }
|
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.api.message.administrative.IEXSecurityDirectoryMessage.createIEXMessage;
|
package pl.zankowski.iextrading4j.hist.perf;
public class LotsOfEnumsBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("LotsOfEnumsMessage.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXSecurityDirectoryMessage.java
// public static IEXSecurityDirectoryMessage createIEXMessage(final byte[] bytes) {
// final byte iexSecurityDirectoryFlag = bytes[1];
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
// final int roundLotSize = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 18, 22));
// final IEXPrice adjustedPOCPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 22, 30));
// final IEXLULDTier iexluldTier = IEXLULDTier.getLULDTier(bytes[30]);
//
// return new IEXSecurityDirectoryMessage(iexSecurityDirectoryFlag, timestamp, symbol, roundLotSize,
// adjustedPOCPrice, iexluldTier);
// }
// Path: iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/LotsOfEnumsBenchmark.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.api.message.administrative.IEXSecurityDirectoryMessage.createIEXMessage;
package pl.zankowski.iextrading4j.hist.perf;
public class LotsOfEnumsBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("LotsOfEnumsMessage.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
public IEXMessage lotsOfEnumsBenchmark(final LotsOfEnumsBenchmark.BenchmarkState benchmarkState) {
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/LotsOfEnumsBenchmark.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXSecurityDirectoryMessage.java
// public static IEXSecurityDirectoryMessage createIEXMessage(final byte[] bytes) {
// final byte iexSecurityDirectoryFlag = bytes[1];
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
// final int roundLotSize = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 18, 22));
// final IEXPrice adjustedPOCPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 22, 30));
// final IEXLULDTier iexluldTier = IEXLULDTier.getLULDTier(bytes[30]);
//
// return new IEXSecurityDirectoryMessage(iexSecurityDirectoryFlag, timestamp, symbol, roundLotSize,
// adjustedPOCPrice, iexluldTier);
// }
|
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.api.message.administrative.IEXSecurityDirectoryMessage.createIEXMessage;
|
package pl.zankowski.iextrading4j.hist.perf;
public class LotsOfEnumsBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("LotsOfEnumsMessage.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public IEXMessage lotsOfEnumsBenchmark(final LotsOfEnumsBenchmark.BenchmarkState benchmarkState) {
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXSecurityDirectoryMessage.java
// public static IEXSecurityDirectoryMessage createIEXMessage(final byte[] bytes) {
// final byte iexSecurityDirectoryFlag = bytes[1];
// final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
// final String symbol = IEXByteConverter.convertBytesToString(Arrays.copyOfRange(bytes, 10, 18));
// final int roundLotSize = IEXByteConverter.convertBytesToInt(Arrays.copyOfRange(bytes, 18, 22));
// final IEXPrice adjustedPOCPrice = IEXByteConverter.convertBytesToIEXPrice(Arrays.copyOfRange(bytes, 22, 30));
// final IEXLULDTier iexluldTier = IEXLULDTier.getLULDTier(bytes[30]);
//
// return new IEXSecurityDirectoryMessage(iexSecurityDirectoryFlag, timestamp, symbol, roundLotSize,
// adjustedPOCPrice, iexluldTier);
// }
// Path: iextrading4j-hist-performance/src/main/java/pl/zankowski/iextrading4j/hist/perf/LotsOfEnumsBenchmark.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static pl.zankowski.iextrading4j.hist.api.message.administrative.IEXSecurityDirectoryMessage.createIEXMessage;
package pl.zankowski.iextrading4j.hist.perf;
public class LotsOfEnumsBenchmark extends PerformanceTestBase {
@State(Scope.Benchmark)
public static class BenchmarkState {
public byte[] packet;
@Setup(Level.Trial)
public void doSetup() throws IOException {
packet = loadPacket("LotsOfEnumsMessage.dump");
}
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public IEXMessage lotsOfEnumsBenchmark(final LotsOfEnumsBenchmark.BenchmarkState benchmarkState) {
|
return createIEXMessage(benchmarkState.packet);
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXOperationalHaltStatusMessage.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXOperationalHaltStatus.java
// public enum IEXOperationalHaltStatus implements IEXByteEnum {
//
// OPERATIONAL_TRADING_HALt((byte) 0x4f),
// NOT_OPERATIONAL_HALTED((byte) 0x4e);
//
// private static final Map<Byte, IEXOperationalHaltStatus> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXOperationalHaltStatus value : EnumSet.allOf(IEXOperationalHaltStatus.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXOperationalHaltStatus(final byte code) {
// this.code = code;
// }
//
// public static IEXOperationalHaltStatus getOperationalHaltStatus(final byte code) {
// return lookup(IEXOperationalHaltStatus.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXOperationalHaltStatus;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.OPERATIONAL_HALT_STATUS;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXOperationalHaltStatusMessage extends IEXMessage {
public static final int LENGTH = 18;
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXOperationalHaltStatus.java
// public enum IEXOperationalHaltStatus implements IEXByteEnum {
//
// OPERATIONAL_TRADING_HALt((byte) 0x4f),
// NOT_OPERATIONAL_HALTED((byte) 0x4e);
//
// private static final Map<Byte, IEXOperationalHaltStatus> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXOperationalHaltStatus value : EnumSet.allOf(IEXOperationalHaltStatus.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXOperationalHaltStatus(final byte code) {
// this.code = code;
// }
//
// public static IEXOperationalHaltStatus getOperationalHaltStatus(final byte code) {
// return lookup(IEXOperationalHaltStatus.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXOperationalHaltStatusMessage.java
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXOperationalHaltStatus;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.OPERATIONAL_HALT_STATUS;
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXOperationalHaltStatusMessage extends IEXMessage {
public static final int LENGTH = 18;
|
private final IEXOperationalHaltStatus operationalHaltStatus;
|
WojciechZankowski/iextrading4j-hist
|
iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXOperationalHaltStatusMessage.java
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXOperationalHaltStatus.java
// public enum IEXOperationalHaltStatus implements IEXByteEnum {
//
// OPERATIONAL_TRADING_HALt((byte) 0x4f),
// NOT_OPERATIONAL_HALTED((byte) 0x4e);
//
// private static final Map<Byte, IEXOperationalHaltStatus> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXOperationalHaltStatus value : EnumSet.allOf(IEXOperationalHaltStatus.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXOperationalHaltStatus(final byte code) {
// this.code = code;
// }
//
// public static IEXOperationalHaltStatus getOperationalHaltStatus(final byte code) {
// return lookup(IEXOperationalHaltStatus.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
|
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXOperationalHaltStatus;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.OPERATIONAL_HALT_STATUS;
|
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXOperationalHaltStatusMessage extends IEXMessage {
public static final int LENGTH = 18;
private final IEXOperationalHaltStatus operationalHaltStatus;
private final long timestamp;
private final String symbol;
private IEXOperationalHaltStatusMessage(
final IEXOperationalHaltStatus operationalHaltStatus,
final long timestamp,
final String symbol) {
super(OPERATIONAL_HALT_STATUS);
this.operationalHaltStatus = operationalHaltStatus;
this.timestamp = timestamp;
this.symbol = symbol;
}
public static IEXOperationalHaltStatusMessage createIEXMessage(final byte[] bytes) {
final IEXOperationalHaltStatus operationalHaltStatus = IEXOperationalHaltStatus.getOperationalHaltStatus(bytes[1]);
|
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/IEXMessage.java
// public abstract class IEXMessage implements Serializable {
//
// private final IEXMessageType messageType;
//
// public IEXMessage(final IEXMessageType messageType) {
// this.messageType = messageType;
// }
//
// public IEXMessageType getMessageType() {
// return messageType;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// final IEXMessage that = (IEXMessage) o;
// return messageType == that.messageType;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(messageType);
// }
//
// @Override
// public String toString() {
// return "IEXMessage{" +
// "messageType=" + messageType +
// '}';
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/field/IEXOperationalHaltStatus.java
// public enum IEXOperationalHaltStatus implements IEXByteEnum {
//
// OPERATIONAL_TRADING_HALt((byte) 0x4f),
// NOT_OPERATIONAL_HALTED((byte) 0x4e);
//
// private static final Map<Byte, IEXOperationalHaltStatus> LOOKUP = new HashMap<>();
//
// static {
// for (final IEXOperationalHaltStatus value : EnumSet.allOf(IEXOperationalHaltStatus.class))
// LOOKUP.put(value.getCode(), value);
// }
//
// private final byte code;
//
// IEXOperationalHaltStatus(final byte code) {
// this.code = code;
// }
//
// public static IEXOperationalHaltStatus getOperationalHaltStatus(final byte code) {
// return lookup(IEXOperationalHaltStatus.class, LOOKUP, code);
// }
//
// @Override
// public byte getCode() {
// return code;
// }
// }
//
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/util/IEXByteConverter.java
// public class IEXByteConverter {
//
// private IEXByteConverter() {
// }
//
// public static long convertBytesToLong(final byte[] bytes) {
// return (long) (0xff & bytes[7]) << 56 |
// (long) (0xff & bytes[6]) << 48 |
// (long) (0xff & bytes[5]) << 40 |
// (long) (0xff & bytes[4]) << 32 |
// (long) (0xff & bytes[3]) << 24 |
// (long) (0xff & bytes[2]) << 16 |
// (long) (0xff & bytes[1]) << 8 |
// (long) (0xff & bytes[0]) << 0;
// }
//
// public static int convertBytesToInt(final byte[] bytes) {
// return ((0xff & bytes[3]) << 24 |
// (0xff & bytes[2]) << 16 |
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0
// );
// }
//
// public static byte[] toByteArray(int value) {
// return new byte[]{
// (byte) value,
// (byte) (value >> 8 & 0xFF),
// (byte) (value >> 16 & 0xFF),
// (byte) (value >> 24 & 0xFF)};
// }
//
// public static int convertBytesToUnsignedShort(final byte[] bytes) {
// return convertBytesToShort(bytes) & 0xffff;
// }
//
// public static short convertBytesToShort(final byte[] bytes) {
// return (short) (
// (0xff & bytes[1]) << 8 |
// (0xff & bytes[0]) << 0);
// }
//
// public static String convertBytesToString(final byte[] bytes) {
// return new String(bytes).trim();
// }
//
// public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) {
// return new IEXPrice(convertBytesToLong(bytes));
// }
//
// public static byte[] convertToRightPaddedString(final String value, final int size) {
// byte[] outputArray = new byte[size];
// Arrays.fill(outputArray, (byte) ' ');
// final byte[] valueArray = value.getBytes(StandardCharsets.UTF_8);
// if (valueArray.length > outputArray.length) {
// throw new ArrayIndexOutOfBoundsException();
// }
// System.arraycopy(valueArray, 0, outputArray, 0, valueArray.length);
// return outputArray;
// }
// }
// Path: iextrading4j-hist-api/src/main/java/pl/zankowski/iextrading4j/hist/api/message/administrative/IEXOperationalHaltStatusMessage.java
import pl.zankowski.iextrading4j.hist.api.message.IEXMessage;
import pl.zankowski.iextrading4j.hist.api.message.administrative.field.IEXOperationalHaltStatus;
import pl.zankowski.iextrading4j.hist.api.util.IEXByteConverter;
import java.util.Arrays;
import java.util.Objects;
import static pl.zankowski.iextrading4j.hist.api.IEXMessageType.OPERATIONAL_HALT_STATUS;
package pl.zankowski.iextrading4j.hist.api.message.administrative;
public class IEXOperationalHaltStatusMessage extends IEXMessage {
public static final int LENGTH = 18;
private final IEXOperationalHaltStatus operationalHaltStatus;
private final long timestamp;
private final String symbol;
private IEXOperationalHaltStatusMessage(
final IEXOperationalHaltStatus operationalHaltStatus,
final long timestamp,
final String symbol) {
super(OPERATIONAL_HALT_STATUS);
this.operationalHaltStatus = operationalHaltStatus;
this.timestamp = timestamp;
this.symbol = symbol;
}
public static IEXOperationalHaltStatusMessage createIEXMessage(final byte[] bytes) {
final IEXOperationalHaltStatus operationalHaltStatus = IEXOperationalHaltStatus.getOperationalHaltStatus(bytes[1]);
|
final long timestamp = IEXByteConverter.convertBytesToLong(Arrays.copyOfRange(bytes, 2, 10));
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/activities/fragments/ChecksApplicationsPage.java
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ChecksItemsListAdapter.java
// public class ChecksItemsListAdapter extends BaseServiceAdapter<Item> {
//
// private static final String TAG = ChecksItemsListAdapter.class
// .getSimpleName();
// private int mTextViewResourceId = R.layout.list_item_items;
//
// /**
// * Constructor.
// *
// * @param service
// * @param textViewResourceId
// */
// public ChecksItemsListAdapter(ZabbixDataService service) {
// super(service);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View row = convertView;
//
// if (row == null) {
// row = getInflater().inflate(mTextViewResourceId, parent, false);
//
// }
//
// TextView clock = (TextView) row.findViewById(R.id.item_clock);
// TextView name = (TextView) row.findViewById(R.id.item_name);
// TextView value = (TextView) row.findViewById(R.id.item_value);
//
// Item i = getItem(position);
//
// Calendar cal = Calendar.getInstance();
// cal.setTimeInMillis(i.getLastClock());
// DateFormat dateFormatter = SimpleDateFormat.getDateTimeInstance(
// SimpleDateFormat.SHORT, SimpleDateFormat.SHORT,
// Locale.getDefault());
// clock.setText(dateFormatter.format(cal.getTime()));
// name.setText(i.getDescription());
// value.setText(i.getLastValue() + " " + i.getUnits());
//
// return row;
// }
//
// @Override
// public long getItemId(int position) {
// Item item = getItem(position);
// if(item != null)
// return item.getId();
// return 0;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnChecksItemSelectedListener.java
// public interface OnChecksItemSelectedListener {
//
// /**
// * Callback method for the selection of a host.
// *
// * @param position
// * list position
// * @param id
// * event ID (Zabbix event_id)
// */
// public void onHostSelected(int position, long id);
//
// /**
// * Callback method for the selection of an application.
// *
// * @param position
// * list position
// */
// public void onApplicationSelected(int position);
//
// /**
// * Callback method for the selection of an item.
// *
// * @param position
// * list position
// * @param item
// * the selected item
// * @param showItemDetails
// * whether or not the item details shall be shown (at activity
// * startup, the details shall not be shown)
// */
// public void onItemSelected(int position, Item item, boolean showItemDetails);
//
// }
|
import com.inovex.zabbixmobile.listeners.OnChecksItemSelectedListener;
import com.inovex.zabbixmobile.listeners.OnItemsLoadedListener;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ChecksItemsListAdapter;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* A page representing one particular application and thus containing a list of
* all items in this application.
*
*/
public class ChecksApplicationsPage extends BaseServiceConnectedListFragment implements OnItemsLoadedListener {
private String mTitle = "";
public static String TAG = ChecksApplicationsPage.class.getSimpleName();
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ChecksItemsListAdapter.java
// public class ChecksItemsListAdapter extends BaseServiceAdapter<Item> {
//
// private static final String TAG = ChecksItemsListAdapter.class
// .getSimpleName();
// private int mTextViewResourceId = R.layout.list_item_items;
//
// /**
// * Constructor.
// *
// * @param service
// * @param textViewResourceId
// */
// public ChecksItemsListAdapter(ZabbixDataService service) {
// super(service);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View row = convertView;
//
// if (row == null) {
// row = getInflater().inflate(mTextViewResourceId, parent, false);
//
// }
//
// TextView clock = (TextView) row.findViewById(R.id.item_clock);
// TextView name = (TextView) row.findViewById(R.id.item_name);
// TextView value = (TextView) row.findViewById(R.id.item_value);
//
// Item i = getItem(position);
//
// Calendar cal = Calendar.getInstance();
// cal.setTimeInMillis(i.getLastClock());
// DateFormat dateFormatter = SimpleDateFormat.getDateTimeInstance(
// SimpleDateFormat.SHORT, SimpleDateFormat.SHORT,
// Locale.getDefault());
// clock.setText(dateFormatter.format(cal.getTime()));
// name.setText(i.getDescription());
// value.setText(i.getLastValue() + " " + i.getUnits());
//
// return row;
// }
//
// @Override
// public long getItemId(int position) {
// Item item = getItem(position);
// if(item != null)
// return item.getId();
// return 0;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnChecksItemSelectedListener.java
// public interface OnChecksItemSelectedListener {
//
// /**
// * Callback method for the selection of a host.
// *
// * @param position
// * list position
// * @param id
// * event ID (Zabbix event_id)
// */
// public void onHostSelected(int position, long id);
//
// /**
// * Callback method for the selection of an application.
// *
// * @param position
// * list position
// */
// public void onApplicationSelected(int position);
//
// /**
// * Callback method for the selection of an item.
// *
// * @param position
// * list position
// * @param item
// * the selected item
// * @param showItemDetails
// * whether or not the item details shall be shown (at activity
// * startup, the details shall not be shown)
// */
// public void onItemSelected(int position, Item item, boolean showItemDetails);
//
// }
// Path: src/main/java/com/inovex/zabbixmobile/activities/fragments/ChecksApplicationsPage.java
import com.inovex.zabbixmobile.listeners.OnChecksItemSelectedListener;
import com.inovex.zabbixmobile.listeners.OnItemsLoadedListener;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ChecksItemsListAdapter;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* A page representing one particular application and thus containing a list of
* all items in this application.
*
*/
public class ChecksApplicationsPage extends BaseServiceConnectedListFragment implements OnItemsLoadedListener {
private String mTitle = "";
public static String TAG = ChecksApplicationsPage.class.getSimpleName();
|
private OnChecksItemSelectedListener mCallbackMain;
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/activities/fragments/ChecksApplicationsPage.java
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ChecksItemsListAdapter.java
// public class ChecksItemsListAdapter extends BaseServiceAdapter<Item> {
//
// private static final String TAG = ChecksItemsListAdapter.class
// .getSimpleName();
// private int mTextViewResourceId = R.layout.list_item_items;
//
// /**
// * Constructor.
// *
// * @param service
// * @param textViewResourceId
// */
// public ChecksItemsListAdapter(ZabbixDataService service) {
// super(service);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View row = convertView;
//
// if (row == null) {
// row = getInflater().inflate(mTextViewResourceId, parent, false);
//
// }
//
// TextView clock = (TextView) row.findViewById(R.id.item_clock);
// TextView name = (TextView) row.findViewById(R.id.item_name);
// TextView value = (TextView) row.findViewById(R.id.item_value);
//
// Item i = getItem(position);
//
// Calendar cal = Calendar.getInstance();
// cal.setTimeInMillis(i.getLastClock());
// DateFormat dateFormatter = SimpleDateFormat.getDateTimeInstance(
// SimpleDateFormat.SHORT, SimpleDateFormat.SHORT,
// Locale.getDefault());
// clock.setText(dateFormatter.format(cal.getTime()));
// name.setText(i.getDescription());
// value.setText(i.getLastValue() + " " + i.getUnits());
//
// return row;
// }
//
// @Override
// public long getItemId(int position) {
// Item item = getItem(position);
// if(item != null)
// return item.getId();
// return 0;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnChecksItemSelectedListener.java
// public interface OnChecksItemSelectedListener {
//
// /**
// * Callback method for the selection of a host.
// *
// * @param position
// * list position
// * @param id
// * event ID (Zabbix event_id)
// */
// public void onHostSelected(int position, long id);
//
// /**
// * Callback method for the selection of an application.
// *
// * @param position
// * list position
// */
// public void onApplicationSelected(int position);
//
// /**
// * Callback method for the selection of an item.
// *
// * @param position
// * list position
// * @param item
// * the selected item
// * @param showItemDetails
// * whether or not the item details shall be shown (at activity
// * startup, the details shall not be shown)
// */
// public void onItemSelected(int position, Item item, boolean showItemDetails);
//
// }
|
import com.inovex.zabbixmobile.listeners.OnChecksItemSelectedListener;
import com.inovex.zabbixmobile.listeners.OnItemsLoadedListener;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ChecksItemsListAdapter;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* A page representing one particular application and thus containing a list of
* all items in this application.
*
*/
public class ChecksApplicationsPage extends BaseServiceConnectedListFragment implements OnItemsLoadedListener {
private String mTitle = "";
public static String TAG = ChecksApplicationsPage.class.getSimpleName();
private OnChecksItemSelectedListener mCallbackMain;
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ChecksItemsListAdapter.java
// public class ChecksItemsListAdapter extends BaseServiceAdapter<Item> {
//
// private static final String TAG = ChecksItemsListAdapter.class
// .getSimpleName();
// private int mTextViewResourceId = R.layout.list_item_items;
//
// /**
// * Constructor.
// *
// * @param service
// * @param textViewResourceId
// */
// public ChecksItemsListAdapter(ZabbixDataService service) {
// super(service);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View row = convertView;
//
// if (row == null) {
// row = getInflater().inflate(mTextViewResourceId, parent, false);
//
// }
//
// TextView clock = (TextView) row.findViewById(R.id.item_clock);
// TextView name = (TextView) row.findViewById(R.id.item_name);
// TextView value = (TextView) row.findViewById(R.id.item_value);
//
// Item i = getItem(position);
//
// Calendar cal = Calendar.getInstance();
// cal.setTimeInMillis(i.getLastClock());
// DateFormat dateFormatter = SimpleDateFormat.getDateTimeInstance(
// SimpleDateFormat.SHORT, SimpleDateFormat.SHORT,
// Locale.getDefault());
// clock.setText(dateFormatter.format(cal.getTime()));
// name.setText(i.getDescription());
// value.setText(i.getLastValue() + " " + i.getUnits());
//
// return row;
// }
//
// @Override
// public long getItemId(int position) {
// Item item = getItem(position);
// if(item != null)
// return item.getId();
// return 0;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnChecksItemSelectedListener.java
// public interface OnChecksItemSelectedListener {
//
// /**
// * Callback method for the selection of a host.
// *
// * @param position
// * list position
// * @param id
// * event ID (Zabbix event_id)
// */
// public void onHostSelected(int position, long id);
//
// /**
// * Callback method for the selection of an application.
// *
// * @param position
// * list position
// */
// public void onApplicationSelected(int position);
//
// /**
// * Callback method for the selection of an item.
// *
// * @param position
// * list position
// * @param item
// * the selected item
// * @param showItemDetails
// * whether or not the item details shall be shown (at activity
// * startup, the details shall not be shown)
// */
// public void onItemSelected(int position, Item item, boolean showItemDetails);
//
// }
// Path: src/main/java/com/inovex/zabbixmobile/activities/fragments/ChecksApplicationsPage.java
import com.inovex.zabbixmobile.listeners.OnChecksItemSelectedListener;
import com.inovex.zabbixmobile.listeners.OnItemsLoadedListener;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ChecksItemsListAdapter;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* A page representing one particular application and thus containing a list of
* all items in this application.
*
*/
public class ChecksApplicationsPage extends BaseServiceConnectedListFragment implements OnItemsLoadedListener {
private String mTitle = "";
public static String TAG = ChecksApplicationsPage.class.getSimpleName();
private OnChecksItemSelectedListener mCallbackMain;
|
private ChecksItemsListAdapter mListAdapter;
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/activities/fragments/BaseSeverityFilterListFragment.java
|
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnSeveritySelectedListener.java
// public interface OnSeveritySelectedListener {
//
// /**
// * Called when a particular severity has been selected.
// *
// * @param severity
// * the selected severity
// */
// public void onSeveritySelected(TriggerSeverity severity);
// }
|
import com.inovex.zabbixmobile.adapters.BaseSeverityListPagerAdapter;
import com.inovex.zabbixmobile.listeners.OnSeveritySelectedListener;
import com.inovex.zabbixmobile.model.TriggerSeverity;
import android.app.Activity;
import android.content.ComponentName;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import com.inovex.zabbixmobile.R;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Base class for a list fragment of a data type to be filtered by severity.
*
* @param <T>
* the data type
*/
public abstract class BaseSeverityFilterListFragment<T> extends
BaseServiceConnectedFragment {
public static final String TAG = BaseSeverityFilterListFragment.class
.getSimpleName();
private static final String ARG_SPINNER_VISIBLE = "arg_spinner_visible";
ViewPager mSeverityListPager;
BaseSeverityListPagerAdapter<T> mSeverityListPagerAdapter;
|
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnSeveritySelectedListener.java
// public interface OnSeveritySelectedListener {
//
// /**
// * Called when a particular severity has been selected.
// *
// * @param severity
// * the selected severity
// */
// public void onSeveritySelected(TriggerSeverity severity);
// }
// Path: src/main/java/com/inovex/zabbixmobile/activities/fragments/BaseSeverityFilterListFragment.java
import com.inovex.zabbixmobile.adapters.BaseSeverityListPagerAdapter;
import com.inovex.zabbixmobile.listeners.OnSeveritySelectedListener;
import com.inovex.zabbixmobile.model.TriggerSeverity;
import android.app.Activity;
import android.content.ComponentName;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import com.inovex.zabbixmobile.R;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Base class for a list fragment of a data type to be filtered by severity.
*
* @param <T>
* the data type
*/
public abstract class BaseSeverityFilterListFragment<T> extends
BaseServiceConnectedFragment {
public static final String TAG = BaseSeverityFilterListFragment.class
.getSimpleName();
private static final String ARG_SPINNER_VISIBLE = "arg_spinner_visible";
ViewPager mSeverityListPager;
BaseSeverityListPagerAdapter<T> mSeverityListPagerAdapter;
|
private OnSeveritySelectedListener mCallbackMain;
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/activities/fragments/BaseSeverityFilterDetailsFragment.java
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/BaseSeverityPagerAdapter.java
// public abstract class BaseSeverityPagerAdapter<T> extends
// BaseServicePagerAdapter<T> {
//
// private static final String TAG = BaseSeverityPagerAdapter.class
// .getSimpleName();
//
// /**
// * Creates an adapter.
// *
// * @param severity
// * severity of this adapter
// */
// public BaseSeverityPagerAdapter(TriggerSeverity severity) {
// this(null, severity);
// }
//
// /**
// * Creates an adapter
// *
// * @param fm
// * the fragment manager to be used by this view pager.
// * @param severity
// * severity of this adapter
// */
// public BaseSeverityPagerAdapter(FragmentManager fm, TriggerSeverity severity) {
// super();
// mFragmentManager = fm;
// Log.d(TAG, "creating SeverityPagerAdapter for severity " + severity);
//
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// return (position + 1) + " of " + getCount();
// }
//
// @Override
// public int getItemPosition(Object object) {
// // This prevents caching of fragments. We need to disable caching
// // because we have only one adapter which is reused when another host is
// // selected.
// return POSITION_NONE;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/model/Sharable.java
// public interface Sharable {
//
// /**
// * Return the string to be used for sharing an object's contents with other
// * applications.
// *
// * @param context
// * the app's context; used to resolve constant string resources
// * @return string to be shared
// */
// public String getSharableString(Context context);
// }
|
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.ShareActionProvider;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.BaseSeverityPagerAdapter;
import com.inovex.zabbixmobile.listeners.OnListItemSelectedListener;
import com.inovex.zabbixmobile.model.Sharable;
import com.inovex.zabbixmobile.model.TriggerSeverity;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Base class for a details fragment of a data type to be filtered by severity.
*
* @param <T>
* the data type
*/
public abstract class BaseSeverityFilterDetailsFragment<T extends Sharable>
extends BaseServiceConnectedFragment {
public static final String TAG = BaseSeverityFilterDetailsFragment.class
.getSimpleName();
private static final String ARG_SEVERITY = "arg_severity";
private static final String ARG_SPINNER_VISIBLE = "arg_spinner_visible";
protected ViewPager mDetailsPager;
protected TriggerSeverity mSeverity = TriggerSeverity.ALL;
private OnListItemSelectedListener mCallbackMain;
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/BaseSeverityPagerAdapter.java
// public abstract class BaseSeverityPagerAdapter<T> extends
// BaseServicePagerAdapter<T> {
//
// private static final String TAG = BaseSeverityPagerAdapter.class
// .getSimpleName();
//
// /**
// * Creates an adapter.
// *
// * @param severity
// * severity of this adapter
// */
// public BaseSeverityPagerAdapter(TriggerSeverity severity) {
// this(null, severity);
// }
//
// /**
// * Creates an adapter
// *
// * @param fm
// * the fragment manager to be used by this view pager.
// * @param severity
// * severity of this adapter
// */
// public BaseSeverityPagerAdapter(FragmentManager fm, TriggerSeverity severity) {
// super();
// mFragmentManager = fm;
// Log.d(TAG, "creating SeverityPagerAdapter for severity " + severity);
//
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// return (position + 1) + " of " + getCount();
// }
//
// @Override
// public int getItemPosition(Object object) {
// // This prevents caching of fragments. We need to disable caching
// // because we have only one adapter which is reused when another host is
// // selected.
// return POSITION_NONE;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/model/Sharable.java
// public interface Sharable {
//
// /**
// * Return the string to be used for sharing an object's contents with other
// * applications.
// *
// * @param context
// * the app's context; used to resolve constant string resources
// * @return string to be shared
// */
// public String getSharableString(Context context);
// }
// Path: src/main/java/com/inovex/zabbixmobile/activities/fragments/BaseSeverityFilterDetailsFragment.java
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.ShareActionProvider;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.BaseSeverityPagerAdapter;
import com.inovex.zabbixmobile.listeners.OnListItemSelectedListener;
import com.inovex.zabbixmobile.model.Sharable;
import com.inovex.zabbixmobile.model.TriggerSeverity;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Base class for a details fragment of a data type to be filtered by severity.
*
* @param <T>
* the data type
*/
public abstract class BaseSeverityFilterDetailsFragment<T extends Sharable>
extends BaseServiceConnectedFragment {
public static final String TAG = BaseSeverityFilterDetailsFragment.class
.getSimpleName();
private static final String ARG_SEVERITY = "arg_severity";
private static final String ARG_SPINNER_VISIBLE = "arg_spinner_visible";
protected ViewPager mDetailsPager;
protected TriggerSeverity mSeverity = TriggerSeverity.ALL;
private OnListItemSelectedListener mCallbackMain;
|
protected BaseSeverityPagerAdapter<T> mDetailsPagerAdapter;
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/push/gcm/RegistrationIntentService.java
|
// Path: src/main/java/com/inovex/zabbixmobile/model/ZaxPreferences.java
// public class ZaxPreferences {
//
// private SharedPreferences mPref;
//
// public static ZaxPreferences getInstance(Context context) {
// return (new ZaxPreferences(context));
// }
//
// private ZaxPreferences(Context context) {
// refresh(context);
// }
//
// public int getWidgetRefreshInterval() {
// try {
// return Integer.parseInt(mPref.getString(
// "widget_refresh_interval_mins", "15"));
// } catch (NumberFormatException e) {
// return 0;
// }
// }
//
// public void registerOnSharedPreferenceChangeListener(
// OnSharedPreferenceChangeListener listener) {
// mPref.registerOnSharedPreferenceChangeListener(listener);
// }
//
// public void unregisterOnSharedPreferenceChangeListener(
// OnSharedPreferenceChangeListener listener) {
// mPref.unregisterOnSharedPreferenceChangeListener(listener);
// }
//
// public boolean isDarkTheme() {
// return mPref.getBoolean("dark_theme", false);
// }
//
// public String getPersistedServerName(){
// return mPref.getString("server_name", "");
// }
//
// public void setPersistedServerName(String name){
// Editor edit = mPref.edit();
// edit.putString("server_name",name);
// }
//
// public long getServerSelection() {
// return mPref.getLong("server_selection", 0);
// }
//
// public void setServerSelection(long selection) {
// Editor edit = mPref.edit();
// edit.putLong("server_selection", selection);
// edit.commit();
// }
//
// public void refresh(Context context) {
// SharedPreferences pref = PreferenceManager
// .getDefaultSharedPreferences(context);
// mPref = pref;
// }
//
// public boolean hasOldServerPreferences() {
// if (mPref.getString("zabbix_url", null) != null) {
// return true;
// }
// return false;
// }
//
// public void migrateServerPreferences(Context context, long id) {
// ZaxServerPreferences p = new ZaxServerPreferences(context, id, true);
// p.savePrefs();
//
// refresh(context);
// mPref.edit().remove("zabbix_url").commit();
// }
//
// public boolean isOldNotificationIcons() {
// return mPref.getBoolean("zabbix_push_old_icons", false);
// }
//
// public boolean isPushEnabled() {
// return mPref.getBoolean("pubnub_push_enabled", mPref.getBoolean("zabbix_push_enabled",false));
// }
//
// public String getPushRingtone() {
// return mPref.getString("zabbix_push_ringtone", null);
// }
//
// public String getPushOkRingtone(){
// return mPref.getString("push_ok_ringtone", null);
// }
//
// public String getPushSubscribeKey() {
// return mPref.getString("pubnub_push_subscribe_key", mPref.getString("zabbix_push_subscribe_key", "")).trim();
// }
//
// public void setWidgetServer(int mAppWidgetId, long id) {
// Editor edit = mPref.edit();
// edit.putLong("widget_server_"+mAppWidgetId, id);
// edit.commit();
// Log.d("ZaxPreferences", "widget server="+mAppWidgetId+"="+id);
// }
//
// public long getWidgetServer(int mAppWidgetId) {
// Log.d("ZaxPreferences", "get widget server from "+mAppWidgetId+"="+mPref.getLong("widget_server_"+mAppWidgetId, -1));
//
// return mPref.getLong("widget_server_"+mAppWidgetId, -1);
// }
//
// public String getGCMSenderID() {
// return mPref.getString("gcm_sender_id", "");
// }
//
// public void setTokenSentToServer(boolean status){
// mPref.edit().putBoolean("sent_token_to_server",status);
// }
//
// public boolean isTokenSentToServer(){
// return mPref.getBoolean("sent_token_to_server",false);
// }
//
// public String getGCMServerUrl() {
// return mPref.getString("gcm_server_url", "");
// }
//
// public boolean isVibrate() {return mPref.getBoolean("vibrate",true);};
// }
|
import android.app.IntentService;
import android.content.Intent;
import android.util.Log;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import com.google.android.gms.iid.InstanceID;
import com.inovex.zabbixmobile.model.ZaxPreferences;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import javax.net.ssl.SSLHandshakeException;
|
package com.inovex.zabbixmobile.push.gcm;
/**
* Created by felix on 16/10/15.
*/
public class RegistrationIntentService extends IntentService{
private static final String TAG = "RegIntentService";
|
// Path: src/main/java/com/inovex/zabbixmobile/model/ZaxPreferences.java
// public class ZaxPreferences {
//
// private SharedPreferences mPref;
//
// public static ZaxPreferences getInstance(Context context) {
// return (new ZaxPreferences(context));
// }
//
// private ZaxPreferences(Context context) {
// refresh(context);
// }
//
// public int getWidgetRefreshInterval() {
// try {
// return Integer.parseInt(mPref.getString(
// "widget_refresh_interval_mins", "15"));
// } catch (NumberFormatException e) {
// return 0;
// }
// }
//
// public void registerOnSharedPreferenceChangeListener(
// OnSharedPreferenceChangeListener listener) {
// mPref.registerOnSharedPreferenceChangeListener(listener);
// }
//
// public void unregisterOnSharedPreferenceChangeListener(
// OnSharedPreferenceChangeListener listener) {
// mPref.unregisterOnSharedPreferenceChangeListener(listener);
// }
//
// public boolean isDarkTheme() {
// return mPref.getBoolean("dark_theme", false);
// }
//
// public String getPersistedServerName(){
// return mPref.getString("server_name", "");
// }
//
// public void setPersistedServerName(String name){
// Editor edit = mPref.edit();
// edit.putString("server_name",name);
// }
//
// public long getServerSelection() {
// return mPref.getLong("server_selection", 0);
// }
//
// public void setServerSelection(long selection) {
// Editor edit = mPref.edit();
// edit.putLong("server_selection", selection);
// edit.commit();
// }
//
// public void refresh(Context context) {
// SharedPreferences pref = PreferenceManager
// .getDefaultSharedPreferences(context);
// mPref = pref;
// }
//
// public boolean hasOldServerPreferences() {
// if (mPref.getString("zabbix_url", null) != null) {
// return true;
// }
// return false;
// }
//
// public void migrateServerPreferences(Context context, long id) {
// ZaxServerPreferences p = new ZaxServerPreferences(context, id, true);
// p.savePrefs();
//
// refresh(context);
// mPref.edit().remove("zabbix_url").commit();
// }
//
// public boolean isOldNotificationIcons() {
// return mPref.getBoolean("zabbix_push_old_icons", false);
// }
//
// public boolean isPushEnabled() {
// return mPref.getBoolean("pubnub_push_enabled", mPref.getBoolean("zabbix_push_enabled",false));
// }
//
// public String getPushRingtone() {
// return mPref.getString("zabbix_push_ringtone", null);
// }
//
// public String getPushOkRingtone(){
// return mPref.getString("push_ok_ringtone", null);
// }
//
// public String getPushSubscribeKey() {
// return mPref.getString("pubnub_push_subscribe_key", mPref.getString("zabbix_push_subscribe_key", "")).trim();
// }
//
// public void setWidgetServer(int mAppWidgetId, long id) {
// Editor edit = mPref.edit();
// edit.putLong("widget_server_"+mAppWidgetId, id);
// edit.commit();
// Log.d("ZaxPreferences", "widget server="+mAppWidgetId+"="+id);
// }
//
// public long getWidgetServer(int mAppWidgetId) {
// Log.d("ZaxPreferences", "get widget server from "+mAppWidgetId+"="+mPref.getLong("widget_server_"+mAppWidgetId, -1));
//
// return mPref.getLong("widget_server_"+mAppWidgetId, -1);
// }
//
// public String getGCMSenderID() {
// return mPref.getString("gcm_sender_id", "");
// }
//
// public void setTokenSentToServer(boolean status){
// mPref.edit().putBoolean("sent_token_to_server",status);
// }
//
// public boolean isTokenSentToServer(){
// return mPref.getBoolean("sent_token_to_server",false);
// }
//
// public String getGCMServerUrl() {
// return mPref.getString("gcm_server_url", "");
// }
//
// public boolean isVibrate() {return mPref.getBoolean("vibrate",true);};
// }
// Path: src/main/java/com/inovex/zabbixmobile/push/gcm/RegistrationIntentService.java
import android.app.IntentService;
import android.content.Intent;
import android.util.Log;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import com.google.android.gms.iid.InstanceID;
import com.inovex.zabbixmobile.model.ZaxPreferences;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import javax.net.ssl.SSLHandshakeException;
package com.inovex.zabbixmobile.push.gcm;
/**
* Created by felix on 16/10/15.
*/
public class RegistrationIntentService extends IntentService{
private static final String TAG = "RegIntentService";
|
private ZaxPreferences mZaxPreferences;
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/data/RemoteAPITask.java
|
// Path: src/main/java/com/inovex/zabbixmobile/exceptions/ZabbixLoginRequiredException.java
// public class ZabbixLoginRequiredException extends Exception {
//
// private static final long serialVersionUID = 537466652124519153L;
//
// public ZabbixLoginRequiredException() {
//
// }
//
// public ZabbixLoginRequiredException(Throwable t) {
// super(t);
// }
// }
|
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.exceptions.FatalException;
import com.inovex.zabbixmobile.exceptions.FatalException.Type;
import com.inovex.zabbixmobile.exceptions.ZabbixLoginRequiredException;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.data;
/**
* Represents an asynchronous Zabbix API call. This handles
* {@link ZabbixLoginRequiredException} by retrying the API call and
* {@link FatalException} by sending a broadcast containing the error message to
* be displayed by the UI.
*
*/
public abstract class RemoteAPITask extends AsyncTask<Void, Integer, Void> {
private static final String TAG = RemoteAPITask.class.getSimpleName();
private final ZabbixRemoteAPI api;
private Context context;
private FatalException ex = null;
public RemoteAPITask(ZabbixRemoteAPI api, Context context) {
this.api = api;
this.context = context;
}
@Override
protected Void doInBackground(Void... params) {
try {
executeTask();
|
// Path: src/main/java/com/inovex/zabbixmobile/exceptions/ZabbixLoginRequiredException.java
// public class ZabbixLoginRequiredException extends Exception {
//
// private static final long serialVersionUID = 537466652124519153L;
//
// public ZabbixLoginRequiredException() {
//
// }
//
// public ZabbixLoginRequiredException(Throwable t) {
// super(t);
// }
// }
// Path: src/main/java/com/inovex/zabbixmobile/data/RemoteAPITask.java
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.exceptions.FatalException;
import com.inovex.zabbixmobile.exceptions.FatalException.Type;
import com.inovex.zabbixmobile.exceptions.ZabbixLoginRequiredException;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.data;
/**
* Represents an asynchronous Zabbix API call. This handles
* {@link ZabbixLoginRequiredException} by retrying the API call and
* {@link FatalException} by sending a broadcast containing the error message to
* be displayed by the UI.
*
*/
public abstract class RemoteAPITask extends AsyncTask<Void, Integer, Void> {
private static final String TAG = RemoteAPITask.class.getSimpleName();
private final ZabbixRemoteAPI api;
private Context context;
private FatalException ex = null;
public RemoteAPITask(ZabbixRemoteAPI api, Context context) {
this.api = api;
this.context = context;
}
@Override
protected Void doInBackground(Void... params) {
try {
executeTask();
|
} catch (ZabbixLoginRequiredException e) {
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/activities/BaseHostGroupSpinnerActivity.java
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/HostGroupsSpinnerAdapter.java
// public class HostGroupsSpinnerAdapter extends BaseServiceAdapter<HostGroup> {
//
// private String mTitle;
// private int mHostGroupPosition;
// private OnHostGroupSelectedListener mCallback;
//
// public interface OnHostGroupSelectedListener {
// public void onHostGroupSelected(int position);
// }
//
// public HostGroupsSpinnerAdapter(ZabbixDataService service) {
// super(service);
// addBaseGroups();
// }
//
// public void setCallback(OnHostGroupSelectedListener callback) {
// this.mCallback = callback;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
//
// View actionBarView = getInflater().inflate(
// R.layout.toolbar_spinner_item_actionbar, null);
// TextView subtitle = (TextView) actionBarView
// .findViewById(android.R.id.text2);
// subtitle.setText(getItem(position).getName());
// return actionBarView;
//
// }
//
// @Override
// public View getDropDownView(int position, View convertView, ViewGroup parent) {
// View actionBarDropDownView = getInflater().inflate(
// R.layout.toolbar_spinner_item_dropdown, null);
// TextView dropDownTitle = (TextView) actionBarDropDownView
// .findViewById(android.R.id.text1);
//
// dropDownTitle.setText(getItem(position).getName());
//
// return actionBarDropDownView;
//
// }
//
// public void setTitle(String title) {
// mTitle = title;
// }
//
// @Override
// public long getItemId(int position) {
// HostGroup item = getItem(position);
// if(item != null)
// return item.getGroupId();
// return 0;
// }
//
// @Override
// public void clear() {
// super.clear();
// addBaseGroups();
// }
//
// /**
// * Adds the base host group for the display of all items.
// */
// private void addBaseGroups() {
// mObjects.add(new HostGroup(HostGroup.GROUP_ID_ALL, mZabbixDataService
// .getResources().getString(R.string.hostgroup_all)));
// }
//
// @Override
// public void setCurrentPosition(int position) {
// this.mHostGroupPosition = position;
// }
//
// @Override
// public int getCurrentPosition() {
// return mHostGroupPosition;
// }
//
// public long getCurrentItemId() {
// return getItemId(mHostGroupPosition);
// }
//
// @Override
// public void notifyDataSetChanged() {
// super.notifyDataSetChanged();
// // update the current selection (we might have saved this position
// // before)
// refreshSelection();
// }
//
// public void refreshSelection() {
// if (mCallback != null && mObjects.size() > mHostGroupPosition)
// mCallback.onHostGroupSelected(mHostGroupPosition);
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/adapters/HostGroupsSpinnerAdapter.java
// public interface OnHostGroupSelectedListener {
// public void onHostGroupSelected(int position);
// }
|
import android.content.ComponentName;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Spinner;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.HostGroupsSpinnerAdapter;
import com.inovex.zabbixmobile.adapters.HostGroupsSpinnerAdapter.OnHostGroupSelectedListener;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities;
/**
* Base class for all activities having a host group spinner in the action bar.
*
*/
public abstract class BaseHostGroupSpinnerActivity extends BaseActivity
implements OnHostGroupSelectedListener {
protected static final String TAG = BaseHostGroupSpinnerActivity.class
.getSimpleName();
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/HostGroupsSpinnerAdapter.java
// public class HostGroupsSpinnerAdapter extends BaseServiceAdapter<HostGroup> {
//
// private String mTitle;
// private int mHostGroupPosition;
// private OnHostGroupSelectedListener mCallback;
//
// public interface OnHostGroupSelectedListener {
// public void onHostGroupSelected(int position);
// }
//
// public HostGroupsSpinnerAdapter(ZabbixDataService service) {
// super(service);
// addBaseGroups();
// }
//
// public void setCallback(OnHostGroupSelectedListener callback) {
// this.mCallback = callback;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
//
// View actionBarView = getInflater().inflate(
// R.layout.toolbar_spinner_item_actionbar, null);
// TextView subtitle = (TextView) actionBarView
// .findViewById(android.R.id.text2);
// subtitle.setText(getItem(position).getName());
// return actionBarView;
//
// }
//
// @Override
// public View getDropDownView(int position, View convertView, ViewGroup parent) {
// View actionBarDropDownView = getInflater().inflate(
// R.layout.toolbar_spinner_item_dropdown, null);
// TextView dropDownTitle = (TextView) actionBarDropDownView
// .findViewById(android.R.id.text1);
//
// dropDownTitle.setText(getItem(position).getName());
//
// return actionBarDropDownView;
//
// }
//
// public void setTitle(String title) {
// mTitle = title;
// }
//
// @Override
// public long getItemId(int position) {
// HostGroup item = getItem(position);
// if(item != null)
// return item.getGroupId();
// return 0;
// }
//
// @Override
// public void clear() {
// super.clear();
// addBaseGroups();
// }
//
// /**
// * Adds the base host group for the display of all items.
// */
// private void addBaseGroups() {
// mObjects.add(new HostGroup(HostGroup.GROUP_ID_ALL, mZabbixDataService
// .getResources().getString(R.string.hostgroup_all)));
// }
//
// @Override
// public void setCurrentPosition(int position) {
// this.mHostGroupPosition = position;
// }
//
// @Override
// public int getCurrentPosition() {
// return mHostGroupPosition;
// }
//
// public long getCurrentItemId() {
// return getItemId(mHostGroupPosition);
// }
//
// @Override
// public void notifyDataSetChanged() {
// super.notifyDataSetChanged();
// // update the current selection (we might have saved this position
// // before)
// refreshSelection();
// }
//
// public void refreshSelection() {
// if (mCallback != null && mObjects.size() > mHostGroupPosition)
// mCallback.onHostGroupSelected(mHostGroupPosition);
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/adapters/HostGroupsSpinnerAdapter.java
// public interface OnHostGroupSelectedListener {
// public void onHostGroupSelected(int position);
// }
// Path: src/main/java/com/inovex/zabbixmobile/activities/BaseHostGroupSpinnerActivity.java
import android.content.ComponentName;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Spinner;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.HostGroupsSpinnerAdapter;
import com.inovex.zabbixmobile.adapters.HostGroupsSpinnerAdapter.OnHostGroupSelectedListener;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX 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 General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities;
/**
* Base class for all activities having a host group spinner in the action bar.
*
*/
public abstract class BaseHostGroupSpinnerActivity extends BaseActivity
implements OnHostGroupSelectedListener {
protected static final String TAG = BaseHostGroupSpinnerActivity.class
.getSimpleName();
|
protected HostGroupsSpinnerAdapter mSpinnerAdapter;
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/model/ZaxServerPreferences.java
|
// Path: src/main/java/com/inovex/zabbixmobile/data/ZabbixAPIVersion.java
// public enum ZabbixAPIVersion {
// API_1_3(0),
// API_1_4(1),
// API_2_0_TO_2_3(2),
// API_2_4(3),
// API_GT_3(4);
//
//
// private final int value;
//
// ZabbixAPIVersion(int value) {
// this.value = value;
// }
//
// public int getValue() {
// return value;
// }
//
// public static ZabbixAPIVersion get(int value) {
// switch (value) {
// case 0:
// return API_1_3;
// case 1:
// return API_1_4;
// case 2:
// return API_2_0_TO_2_3;
// case 3:
// return API_2_4;
// case 4:
// return API_GT_3;
// default:
// return API_1_3;
// }
// }
//
// public boolean isGreater1_4() {
// return value > 0;
// }
//
// public boolean isGreater2_3() {
// return value > 2;
// }
// }
|
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.preference.PreferenceManager;
import android.util.Log;
import com.inovex.zabbixmobile.data.ZabbixAPIVersion;
|
public String getHttpAuthPassword() {
return mPref.getString(serverId + "http_auth_password", "");
}
public String getZabbixUrl() {
return mPref.getString(serverId + "zabbix_url", "");
}
/**
* Checks whether the server settings have been altered by the user
*
* @return true: the server settings are still default
*/
public boolean isDefault() {
String url = mPref.getString("zabbix_url", "");
return (url.equals("http://zabbix.company.net/zabbix"))
|| (url == null) || url.equals("");
}
public void registerOnSharedPreferenceChangeListener(
OnSharedPreferenceChangeListener listener) {
mPref.registerOnSharedPreferenceChangeListener(listener);
}
public void unregisterOnSharedPreferenceChangeListener(
OnSharedPreferenceChangeListener listener) {
mPref.unregisterOnSharedPreferenceChangeListener(listener);
}
|
// Path: src/main/java/com/inovex/zabbixmobile/data/ZabbixAPIVersion.java
// public enum ZabbixAPIVersion {
// API_1_3(0),
// API_1_4(1),
// API_2_0_TO_2_3(2),
// API_2_4(3),
// API_GT_3(4);
//
//
// private final int value;
//
// ZabbixAPIVersion(int value) {
// this.value = value;
// }
//
// public int getValue() {
// return value;
// }
//
// public static ZabbixAPIVersion get(int value) {
// switch (value) {
// case 0:
// return API_1_3;
// case 1:
// return API_1_4;
// case 2:
// return API_2_0_TO_2_3;
// case 3:
// return API_2_4;
// case 4:
// return API_GT_3;
// default:
// return API_1_3;
// }
// }
//
// public boolean isGreater1_4() {
// return value > 0;
// }
//
// public boolean isGreater2_3() {
// return value > 2;
// }
// }
// Path: src/main/java/com/inovex/zabbixmobile/model/ZaxServerPreferences.java
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.preference.PreferenceManager;
import android.util.Log;
import com.inovex.zabbixmobile.data.ZabbixAPIVersion;
public String getHttpAuthPassword() {
return mPref.getString(serverId + "http_auth_password", "");
}
public String getZabbixUrl() {
return mPref.getString(serverId + "zabbix_url", "");
}
/**
* Checks whether the server settings have been altered by the user
*
* @return true: the server settings are still default
*/
public boolean isDefault() {
String url = mPref.getString("zabbix_url", "");
return (url.equals("http://zabbix.company.net/zabbix"))
|| (url == null) || url.equals("");
}
public void registerOnSharedPreferenceChangeListener(
OnSharedPreferenceChangeListener listener) {
mPref.registerOnSharedPreferenceChangeListener(listener);
}
public void unregisterOnSharedPreferenceChangeListener(
OnSharedPreferenceChangeListener listener) {
mPref.unregisterOnSharedPreferenceChangeListener(listener);
}
|
public void setZabbixAPIVersion(ZabbixAPIVersion version) {
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.