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 |
|---|---|---|---|---|---|---|
google/agera | agera/src/test/java/com/google/android/agera/ReceiversTest.java | // Path: agera/src/main/java/com/google/android/agera/Receivers.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Receiver<T> nullReceiver() {
// return NULL_OPERATOR;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Receivers.nullReceiver;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Test; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ReceiversTest {
private static final int VALUE = 44;
@Test
public void shouldHandleCallsToNullReceiver() {
nullReceiver().accept(VALUE);
}
@Test
public void shouldHavePrivateConstructor() { | // Path: agera/src/main/java/com/google/android/agera/Receivers.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Receiver<T> nullReceiver() {
// return NULL_OPERATOR;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ReceiversTest.java
import static com.google.android.agera.Receivers.nullReceiver;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Test;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ReceiversTest {
private static final int VALUE = 44;
@Test
public void shouldHandleCallsToNullReceiver() {
nullReceiver().accept(VALUE);
}
@Test
public void shouldHavePrivateConstructor() { | assertThat(Receivers.class, hasPrivateConstructor()); |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ConditionsTest {
private static final int VALUE = 1;
@Mock
private Condition mockConditionFalse;
@Mock
private Condition mockConditionTrue;
@Mock
private Predicate<Integer> mockPredicateFalse;
@Mock
private Predicate<Integer> mockPredicateTrue;
@Mock
private Supplier<Integer> mockValueSupplier;
@Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE); | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ConditionsTest {
private static final int VALUE = 1;
@Mock
private Condition mockConditionFalse;
@Mock
private Condition mockConditionTrue;
@Mock
private Predicate<Integer> mockPredicateFalse;
@Mock
private Predicate<Integer> mockPredicateTrue;
@Mock
private Supplier<Integer> mockValueSupplier;
@Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE); | when(mockConditionTrue.applies()).thenReturn(true); |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ConditionsTest {
private static final int VALUE = 1;
@Mock
private Condition mockConditionFalse;
@Mock
private Condition mockConditionTrue;
@Mock
private Predicate<Integer> mockPredicateFalse;
@Mock
private Predicate<Integer> mockPredicateTrue;
@Mock
private Supplier<Integer> mockValueSupplier;
@Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE);
when(mockConditionTrue.applies()).thenReturn(true);
when(mockPredicateTrue.apply(anyInt())).thenReturn(true);
}
@Test
public void shouldReturnTrueForTrueCondition() { | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ConditionsTest {
private static final int VALUE = 1;
@Mock
private Condition mockConditionFalse;
@Mock
private Condition mockConditionTrue;
@Mock
private Predicate<Integer> mockPredicateFalse;
@Mock
private Predicate<Integer> mockPredicateTrue;
@Mock
private Supplier<Integer> mockValueSupplier;
@Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE);
when(mockConditionTrue.applies()).thenReturn(true);
when(mockPredicateTrue.apply(anyInt())).thenReturn(true);
}
@Test
public void shouldReturnTrueForTrueCondition() { | assertThat(trueCondition(), applies()); |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ConditionsTest {
private static final int VALUE = 1;
@Mock
private Condition mockConditionFalse;
@Mock
private Condition mockConditionTrue;
@Mock
private Predicate<Integer> mockPredicateFalse;
@Mock
private Predicate<Integer> mockPredicateTrue;
@Mock
private Supplier<Integer> mockValueSupplier;
@Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE);
when(mockConditionTrue.applies()).thenReturn(true);
when(mockPredicateTrue.apply(anyInt())).thenReturn(true);
}
@Test
public void shouldReturnTrueForTrueCondition() {
assertThat(trueCondition(), applies());
}
@Test
public void shouldReturnFalseForFalseCondition() { | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ConditionsTest {
private static final int VALUE = 1;
@Mock
private Condition mockConditionFalse;
@Mock
private Condition mockConditionTrue;
@Mock
private Predicate<Integer> mockPredicateFalse;
@Mock
private Predicate<Integer> mockPredicateTrue;
@Mock
private Supplier<Integer> mockValueSupplier;
@Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE);
when(mockConditionTrue.applies()).thenReturn(true);
when(mockPredicateTrue.apply(anyInt())).thenReturn(true);
}
@Test
public void shouldReturnTrueForTrueCondition() {
assertThat(trueCondition(), applies());
}
@Test
public void shouldReturnFalseForFalseCondition() { | assertThat(falseCondition(), doesNotApply()); |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ConditionsTest {
private static final int VALUE = 1;
@Mock
private Condition mockConditionFalse;
@Mock
private Condition mockConditionTrue;
@Mock
private Predicate<Integer> mockPredicateFalse;
@Mock
private Predicate<Integer> mockPredicateTrue;
@Mock
private Supplier<Integer> mockValueSupplier;
@Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE);
when(mockConditionTrue.applies()).thenReturn(true);
when(mockPredicateTrue.apply(anyInt())).thenReturn(true);
}
@Test
public void shouldReturnTrueForTrueCondition() {
assertThat(trueCondition(), applies());
}
@Test
public void shouldReturnFalseForFalseCondition() { | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ConditionsTest {
private static final int VALUE = 1;
@Mock
private Condition mockConditionFalse;
@Mock
private Condition mockConditionTrue;
@Mock
private Predicate<Integer> mockPredicateFalse;
@Mock
private Predicate<Integer> mockPredicateTrue;
@Mock
private Supplier<Integer> mockValueSupplier;
@Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE);
when(mockConditionTrue.applies()).thenReturn(true);
when(mockPredicateTrue.apply(anyInt())).thenReturn(true);
}
@Test
public void shouldReturnTrueForTrueCondition() {
assertThat(trueCondition(), applies());
}
@Test
public void shouldReturnFalseForFalseCondition() { | assertThat(falseCondition(), doesNotApply()); |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ConditionsTest {
private static final int VALUE = 1;
@Mock
private Condition mockConditionFalse;
@Mock
private Condition mockConditionTrue;
@Mock
private Predicate<Integer> mockPredicateFalse;
@Mock
private Predicate<Integer> mockPredicateTrue;
@Mock
private Supplier<Integer> mockValueSupplier;
@Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE);
when(mockConditionTrue.applies()).thenReturn(true);
when(mockPredicateTrue.apply(anyInt())).thenReturn(true);
}
@Test
public void shouldReturnTrueForTrueCondition() {
assertThat(trueCondition(), applies());
}
@Test
public void shouldReturnFalseForFalseCondition() {
assertThat(falseCondition(), doesNotApply());
}
@Test
public void shouldReturnTrueForTrueStaticCondition() { | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class ConditionsTest {
private static final int VALUE = 1;
@Mock
private Condition mockConditionFalse;
@Mock
private Condition mockConditionTrue;
@Mock
private Predicate<Integer> mockPredicateFalse;
@Mock
private Predicate<Integer> mockPredicateTrue;
@Mock
private Supplier<Integer> mockValueSupplier;
@Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE);
when(mockConditionTrue.applies()).thenReturn(true);
when(mockPredicateTrue.apply(anyInt())).thenReturn(true);
}
@Test
public void shouldReturnTrueForTrueCondition() {
assertThat(trueCondition(), applies());
}
@Test
public void shouldReturnFalseForFalseCondition() {
assertThat(falseCondition(), doesNotApply());
}
@Test
public void shouldReturnTrueForTrueStaticCondition() { | assertThat(staticCondition(true), sameInstance(trueCondition())); |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | @Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE);
when(mockConditionTrue.applies()).thenReturn(true);
when(mockPredicateTrue.apply(anyInt())).thenReturn(true);
}
@Test
public void shouldReturnTrueForTrueCondition() {
assertThat(trueCondition(), applies());
}
@Test
public void shouldReturnFalseForFalseCondition() {
assertThat(falseCondition(), doesNotApply());
}
@Test
public void shouldReturnTrueForTrueStaticCondition() {
assertThat(staticCondition(true), sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForFalseStaticCondition() {
assertThat(staticCondition(false), sameInstance(falseCondition()));
}
@Test
public void shouldNegateTrueCondition() { | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@Before
public void setUp() {
initMocks(this);
when(mockValueSupplier.get()).thenReturn(VALUE);
when(mockConditionTrue.applies()).thenReturn(true);
when(mockPredicateTrue.apply(anyInt())).thenReturn(true);
}
@Test
public void shouldReturnTrueForTrueCondition() {
assertThat(trueCondition(), applies());
}
@Test
public void shouldReturnFalseForFalseCondition() {
assertThat(falseCondition(), doesNotApply());
}
@Test
public void shouldReturnTrueForTrueStaticCondition() {
assertThat(staticCondition(true), sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForFalseStaticCondition() {
assertThat(staticCondition(false), sameInstance(falseCondition()));
}
@Test
public void shouldNegateTrueCondition() { | assertThat(not(trueCondition()), sameInstance(falseCondition())); |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | assertThat(staticCondition(false), sameInstance(falseCondition()));
}
@Test
public void shouldNegateTrueCondition() {
assertThat(not(trueCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldNegateFalseCondition() {
assertThat(not(falseCondition()), sameInstance(trueCondition()));
}
@Test
public void shouldNegateNonStaticFalseCondition() {
assertThat(not(mockConditionFalse), applies());
}
@Test
public void shouldNegateNonStaticTrueCondition() {
assertThat(not(mockConditionTrue), doesNotApply());
}
@Test
public void shouldReturnOriginalConditionIfNegatedTwice() {
assertThat(not(not(mockConditionFalse)), is(sameInstance(mockConditionFalse)));
}
@Test
public void shouldReturnTrueForAllWithNoConditions() { | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
assertThat(staticCondition(false), sameInstance(falseCondition()));
}
@Test
public void shouldNegateTrueCondition() {
assertThat(not(trueCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldNegateFalseCondition() {
assertThat(not(falseCondition()), sameInstance(trueCondition()));
}
@Test
public void shouldNegateNonStaticFalseCondition() {
assertThat(not(mockConditionFalse), applies());
}
@Test
public void shouldNegateNonStaticTrueCondition() {
assertThat(not(mockConditionTrue), doesNotApply());
}
@Test
public void shouldReturnOriginalConditionIfNegatedTwice() {
assertThat(not(not(mockConditionFalse)), is(sameInstance(mockConditionFalse)));
}
@Test
public void shouldReturnTrueForAllWithNoConditions() { | assertThat(all(), sameInstance(trueCondition())); |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | assertThat(all(mockConditionFalse), is(sameInstance(mockConditionFalse)));
}
@Test
public void shouldReturnTrueForAllWithTrueConditions() {
assertThat(all(trueCondition(), trueCondition()), sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForAllWithOneFalseCondition() {
assertThat(all(trueCondition(), falseCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldReturnTrueForAllWithNonStaticTrueConditions() {
assertThat(all(mockConditionTrue, mockConditionTrue), applies());
}
@Test
public void shouldReturnFalseForAllWithNonStaticOneFalseCondition() {
assertThat(all(mockConditionTrue, mockConditionFalse), doesNotApply());
}
@Test
public void shouldReturnFalseForAllWithNonStaticOneStaticFalseCondition() {
assertThat(all(mockConditionTrue, falseCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldReturnFalseForAnyWithNoConditions() { | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
assertThat(all(mockConditionFalse), is(sameInstance(mockConditionFalse)));
}
@Test
public void shouldReturnTrueForAllWithTrueConditions() {
assertThat(all(trueCondition(), trueCondition()), sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForAllWithOneFalseCondition() {
assertThat(all(trueCondition(), falseCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldReturnTrueForAllWithNonStaticTrueConditions() {
assertThat(all(mockConditionTrue, mockConditionTrue), applies());
}
@Test
public void shouldReturnFalseForAllWithNonStaticOneFalseCondition() {
assertThat(all(mockConditionTrue, mockConditionFalse), doesNotApply());
}
@Test
public void shouldReturnFalseForAllWithNonStaticOneStaticFalseCondition() {
assertThat(all(mockConditionTrue, falseCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldReturnFalseForAnyWithNoConditions() { | assertThat(any(), sameInstance(falseCondition())); |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | assertThat(any(), sameInstance(falseCondition()));
}
@Test
public void shouldReturnOriginalConditionIfAnyOfOne() {
assertThat(any(mockConditionFalse), is(sameInstance(mockConditionFalse)));
}
@Test
public void shouldReturnTrueForAnyWithOneTrueCondition() {
assertThat(any(trueCondition(), falseCondition()), sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForAnyWithNoTrueCondition() {
assertThat(any(falseCondition(), falseCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldReturnTrueForAnyWithNonStaticOneTrueCondition() {
assertThat(any(mockConditionTrue, mockConditionFalse), applies());
}
@Test
public void shouldReturnFalseForAnyWithNonStaticNoTrueCondition() {
assertThat(any(mockConditionFalse, mockConditionFalse), doesNotApply());
}
@Test
public void shouldReturnTrueForTruePredicateAsCondition() { | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
assertThat(any(), sameInstance(falseCondition()));
}
@Test
public void shouldReturnOriginalConditionIfAnyOfOne() {
assertThat(any(mockConditionFalse), is(sameInstance(mockConditionFalse)));
}
@Test
public void shouldReturnTrueForAnyWithOneTrueCondition() {
assertThat(any(trueCondition(), falseCondition()), sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForAnyWithNoTrueCondition() {
assertThat(any(falseCondition(), falseCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldReturnTrueForAnyWithNonStaticOneTrueCondition() {
assertThat(any(mockConditionTrue, mockConditionFalse), applies());
}
@Test
public void shouldReturnFalseForAnyWithNonStaticNoTrueCondition() {
assertThat(any(mockConditionFalse, mockConditionFalse), doesNotApply());
}
@Test
public void shouldReturnTrueForTruePredicateAsCondition() { | assertThat(predicateAsCondition(truePredicate(), mockValueSupplier), |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | assertThat(any(), sameInstance(falseCondition()));
}
@Test
public void shouldReturnOriginalConditionIfAnyOfOne() {
assertThat(any(mockConditionFalse), is(sameInstance(mockConditionFalse)));
}
@Test
public void shouldReturnTrueForAnyWithOneTrueCondition() {
assertThat(any(trueCondition(), falseCondition()), sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForAnyWithNoTrueCondition() {
assertThat(any(falseCondition(), falseCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldReturnTrueForAnyWithNonStaticOneTrueCondition() {
assertThat(any(mockConditionTrue, mockConditionFalse), applies());
}
@Test
public void shouldReturnFalseForAnyWithNonStaticNoTrueCondition() {
assertThat(any(mockConditionFalse, mockConditionFalse), doesNotApply());
}
@Test
public void shouldReturnTrueForTruePredicateAsCondition() { | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
assertThat(any(), sameInstance(falseCondition()));
}
@Test
public void shouldReturnOriginalConditionIfAnyOfOne() {
assertThat(any(mockConditionFalse), is(sameInstance(mockConditionFalse)));
}
@Test
public void shouldReturnTrueForAnyWithOneTrueCondition() {
assertThat(any(trueCondition(), falseCondition()), sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForAnyWithNoTrueCondition() {
assertThat(any(falseCondition(), falseCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldReturnTrueForAnyWithNonStaticOneTrueCondition() {
assertThat(any(mockConditionTrue, mockConditionFalse), applies());
}
@Test
public void shouldReturnFalseForAnyWithNonStaticNoTrueCondition() {
assertThat(any(mockConditionFalse, mockConditionFalse), doesNotApply());
}
@Test
public void shouldReturnTrueForTruePredicateAsCondition() { | assertThat(predicateAsCondition(truePredicate(), mockValueSupplier), |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | }
@Test
public void shouldReturnTrueForAnyWithOneTrueCondition() {
assertThat(any(trueCondition(), falseCondition()), sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForAnyWithNoTrueCondition() {
assertThat(any(falseCondition(), falseCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldReturnTrueForAnyWithNonStaticOneTrueCondition() {
assertThat(any(mockConditionTrue, mockConditionFalse), applies());
}
@Test
public void shouldReturnFalseForAnyWithNonStaticNoTrueCondition() {
assertThat(any(mockConditionFalse, mockConditionFalse), doesNotApply());
}
@Test
public void shouldReturnTrueForTruePredicateAsCondition() {
assertThat(predicateAsCondition(truePredicate(), mockValueSupplier),
sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForFalsePredicateAsCondition() { | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
}
@Test
public void shouldReturnTrueForAnyWithOneTrueCondition() {
assertThat(any(trueCondition(), falseCondition()), sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForAnyWithNoTrueCondition() {
assertThat(any(falseCondition(), falseCondition()), sameInstance(falseCondition()));
}
@Test
public void shouldReturnTrueForAnyWithNonStaticOneTrueCondition() {
assertThat(any(mockConditionTrue, mockConditionFalse), applies());
}
@Test
public void shouldReturnFalseForAnyWithNonStaticNoTrueCondition() {
assertThat(any(mockConditionFalse, mockConditionFalse), doesNotApply());
}
@Test
public void shouldReturnTrueForTruePredicateAsCondition() {
assertThat(predicateAsCondition(truePredicate(), mockValueSupplier),
sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForFalsePredicateAsCondition() { | assertThat(predicateAsCondition(falsePredicate(), mockValueSupplier), |
google/agera | agera/src/test/java/com/google/android/agera/ConditionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | @Test
public void shouldReturnFalseForAnyWithNonStaticNoTrueCondition() {
assertThat(any(mockConditionFalse, mockConditionFalse), doesNotApply());
}
@Test
public void shouldReturnTrueForTruePredicateAsCondition() {
assertThat(predicateAsCondition(truePredicate(), mockValueSupplier),
sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForFalsePredicateAsCondition() {
assertThat(predicateAsCondition(falsePredicate(), mockValueSupplier),
sameInstance(falseCondition()));
}
@Test
public void shouldPassSupplierObjectToPredicateForTruePredicateAsCondition() {
assertThat(predicateAsCondition(mockPredicateTrue, mockValueSupplier), applies());
}
@Test
public void shouldPassSupplierObjectToPredicateForFalsePredicateAsCondition() {
assertThat(predicateAsCondition(mockPredicateFalse, mockValueSupplier), doesNotApply());
verify(mockPredicateFalse).apply(VALUE);
}
@Test
public void shouldHavePrivateConstructor() { | // Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition all(@NonNull final Condition... conditions) {
// return composite(conditions, trueCondition(), falseCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition any(@NonNull final Condition... conditions) {
// return composite(conditions, falseCondition(), trueCondition());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition falseCondition() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition not(@NonNull final Condition condition) {
// if (condition instanceof NegatedCondition) {
// return ((NegatedCondition) condition).condition;
// }
// if (condition == TRUE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// if (condition == FALSE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// return new NegatedCondition(condition);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static <T> Condition predicateAsCondition(@NonNull final Predicate<T> predicate,
// @NonNull final Supplier<? extends T> supplier) {
// if (predicate == TRUE_CONDICATE) {
// return TRUE_CONDICATE;
// }
// if (predicate == FALSE_CONDICATE) {
// return FALSE_CONDICATE;
// }
// return new PredicateCondition<>(predicate, supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition staticCondition(final boolean value) {
// return value ? TRUE_CONDICATE : FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Conditions.java
// @NonNull
// public static Condition trueCondition() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> falsePredicate() {
// return FALSE_CONDICATE;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Predicates.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static <T> Predicate<T> truePredicate() {
// return TRUE_CONDICATE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> applies() {
// return new ConditionApplies(true);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/ConditionApplies.java
// @NonNull
// @Factory
// public static Matcher<Condition> doesNotApply() {
// return new ConditionApplies(false);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/ConditionsTest.java
import static com.google.android.agera.Conditions.all;
import static com.google.android.agera.Conditions.any;
import static com.google.android.agera.Conditions.falseCondition;
import static com.google.android.agera.Conditions.not;
import static com.google.android.agera.Conditions.predicateAsCondition;
import static com.google.android.agera.Conditions.staticCondition;
import static com.google.android.agera.Conditions.trueCondition;
import static com.google.android.agera.Predicates.falsePredicate;
import static com.google.android.agera.Predicates.truePredicate;
import static com.google.android.agera.test.matchers.ConditionApplies.applies;
import static com.google.android.agera.test.matchers.ConditionApplies.doesNotApply;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@Test
public void shouldReturnFalseForAnyWithNonStaticNoTrueCondition() {
assertThat(any(mockConditionFalse, mockConditionFalse), doesNotApply());
}
@Test
public void shouldReturnTrueForTruePredicateAsCondition() {
assertThat(predicateAsCondition(truePredicate(), mockValueSupplier),
sameInstance(trueCondition()));
}
@Test
public void shouldReturnFalseForFalsePredicateAsCondition() {
assertThat(predicateAsCondition(falsePredicate(), mockValueSupplier),
sameInstance(falseCondition()));
}
@Test
public void shouldPassSupplierObjectToPredicateForTruePredicateAsCondition() {
assertThat(predicateAsCondition(mockPredicateTrue, mockValueSupplier), applies());
}
@Test
public void shouldPassSupplierObjectToPredicateForFalsePredicateAsCondition() {
assertThat(predicateAsCondition(mockPredicateFalse, mockValueSupplier), doesNotApply());
verify(mockPredicateFalse).apply(VALUE);
}
@Test
public void shouldHavePrivateConstructor() { | assertThat(Conditions.class, hasPrivateConstructor()); |
google/agera | extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
| import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera.net;
public final class HttpRequestTest {
private static final String URL = "http://agera";
private static final byte[] DATA = "Body data".getBytes();
@Test
public void shouldCreateHttpGetRequest() { | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
// Path: extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java
import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera.net;
public final class HttpRequestTest {
private static final String URL = "http://agera";
private static final byte[] DATA = "Body data".getBytes();
@Test
public void shouldCreateHttpGetRequest() { | final HttpRequest httpRequest = httpGetRequest(URL).compile(); |
google/agera | extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
| import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera.net;
public final class HttpRequestTest {
private static final String URL = "http://agera";
private static final byte[] DATA = "Body data".getBytes();
@Test
public void shouldCreateHttpGetRequest() {
final HttpRequest httpRequest = httpGetRequest(URL).compile();
assertThat(httpRequest.method, is("GET"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateHttpPostRequest() { | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
// Path: extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java
import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera.net;
public final class HttpRequestTest {
private static final String URL = "http://agera";
private static final byte[] DATA = "Body data".getBytes();
@Test
public void shouldCreateHttpGetRequest() {
final HttpRequest httpRequest = httpGetRequest(URL).compile();
assertThat(httpRequest.method, is("GET"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateHttpPostRequest() { | final HttpRequest httpRequest = httpPostRequest(URL).compile(); |
google/agera | extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
| import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera.net;
public final class HttpRequestTest {
private static final String URL = "http://agera";
private static final byte[] DATA = "Body data".getBytes();
@Test
public void shouldCreateHttpGetRequest() {
final HttpRequest httpRequest = httpGetRequest(URL).compile();
assertThat(httpRequest.method, is("GET"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateHttpPostRequest() {
final HttpRequest httpRequest = httpPostRequest(URL).compile();
assertThat(httpRequest.method, is("POST"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateHttpPostRequestWithData() {
final HttpRequest httpRequest = httpPostRequest(URL).body(DATA).compile();
assertThat(httpRequest.method, is("POST"));
assertThat(httpRequest.url, is(URL));
assertThat(httpRequest.body, is(DATA));
}
@Test
public void shouldCreateHttpPutRequest() { | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
// Path: extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java
import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera.net;
public final class HttpRequestTest {
private static final String URL = "http://agera";
private static final byte[] DATA = "Body data".getBytes();
@Test
public void shouldCreateHttpGetRequest() {
final HttpRequest httpRequest = httpGetRequest(URL).compile();
assertThat(httpRequest.method, is("GET"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateHttpPostRequest() {
final HttpRequest httpRequest = httpPostRequest(URL).compile();
assertThat(httpRequest.method, is("POST"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateHttpPostRequestWithData() {
final HttpRequest httpRequest = httpPostRequest(URL).body(DATA).compile();
assertThat(httpRequest.method, is("POST"));
assertThat(httpRequest.url, is(URL));
assertThat(httpRequest.body, is(DATA));
}
@Test
public void shouldCreateHttpPutRequest() { | final HttpRequest httpRequest = httpPutRequest(URL).compile(); |
google/agera | extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
| import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile; | }
@Test
public void shouldCreateHttpPostRequestWithData() {
final HttpRequest httpRequest = httpPostRequest(URL).body(DATA).compile();
assertThat(httpRequest.method, is("POST"));
assertThat(httpRequest.url, is(URL));
assertThat(httpRequest.body, is(DATA));
}
@Test
public void shouldCreateHttpPutRequest() {
final HttpRequest httpRequest = httpPutRequest(URL).compile();
assertThat(httpRequest.method, is("PUT"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateHttpPutRequestWithBody() {
final HttpRequest httpRequest = httpPutRequest(URL).body(DATA).compile();
assertThat(httpRequest.method, is("PUT"));
assertThat(httpRequest.url, is(URL));
assertThat(httpRequest.body, is(DATA));
}
@Test
public void shouldCreateHttpDeleteRequest() { | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
// Path: extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java
import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
}
@Test
public void shouldCreateHttpPostRequestWithData() {
final HttpRequest httpRequest = httpPostRequest(URL).body(DATA).compile();
assertThat(httpRequest.method, is("POST"));
assertThat(httpRequest.url, is(URL));
assertThat(httpRequest.body, is(DATA));
}
@Test
public void shouldCreateHttpPutRequest() {
final HttpRequest httpRequest = httpPutRequest(URL).compile();
assertThat(httpRequest.method, is("PUT"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateHttpPutRequestWithBody() {
final HttpRequest httpRequest = httpPutRequest(URL).body(DATA).compile();
assertThat(httpRequest.method, is("PUT"));
assertThat(httpRequest.url, is(URL));
assertThat(httpRequest.body, is(DATA));
}
@Test
public void shouldCreateHttpDeleteRequest() { | final HttpRequest httpRequest = httpDeleteRequest(URL).compile(); |
google/agera | extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
| import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile; |
assertThat(httpRequest.method, is("PUT"));
assertThat(httpRequest.url, is(URL));
assertThat(httpRequest.body, is(DATA));
}
@Test
public void shouldCreateHttpDeleteRequest() {
final HttpRequest httpRequest = httpDeleteRequest(URL).compile();
assertThat(httpRequest.method, is("DELETE"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateSetHeaderFields() {
final HttpRequest httpRequest = httpGetRequest(URL)
.headerField("HEADER1", "VALUE1")
.headerField("HEADER2", "VALUE2")
.compile();
final Map<String, String> header = httpRequest.header;
assertThat(header, hasEntry("HEADER1", "VALUE1"));
assertThat(header, hasEntry("HEADER2", "VALUE2"));
}
@Test
public void shouldHaveDefaultValuesForRedirectCachesAndTimeouts() {
final HttpRequest httpRequest = httpDeleteRequest(URL).compile();
| // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
// Path: extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java
import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
assertThat(httpRequest.method, is("PUT"));
assertThat(httpRequest.url, is(URL));
assertThat(httpRequest.body, is(DATA));
}
@Test
public void shouldCreateHttpDeleteRequest() {
final HttpRequest httpRequest = httpDeleteRequest(URL).compile();
assertThat(httpRequest.method, is("DELETE"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateSetHeaderFields() {
final HttpRequest httpRequest = httpGetRequest(URL)
.headerField("HEADER1", "VALUE1")
.headerField("HEADER2", "VALUE2")
.compile();
final Map<String, String> header = httpRequest.header;
assertThat(header, hasEntry("HEADER1", "VALUE1"));
assertThat(header, hasEntry("HEADER2", "VALUE2"));
}
@Test
public void shouldHaveDefaultValuesForRedirectCachesAndTimeouts() {
final HttpRequest httpRequest = httpDeleteRequest(URL).compile();
| assertThat(httpRequest.connectTimeoutMs, is(CONNECT_TIMEOUT_MS)); |
google/agera | extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
| import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile; | assertThat(httpRequest.method, is("PUT"));
assertThat(httpRequest.url, is(URL));
assertThat(httpRequest.body, is(DATA));
}
@Test
public void shouldCreateHttpDeleteRequest() {
final HttpRequest httpRequest = httpDeleteRequest(URL).compile();
assertThat(httpRequest.method, is("DELETE"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateSetHeaderFields() {
final HttpRequest httpRequest = httpGetRequest(URL)
.headerField("HEADER1", "VALUE1")
.headerField("HEADER2", "VALUE2")
.compile();
final Map<String, String> header = httpRequest.header;
assertThat(header, hasEntry("HEADER1", "VALUE1"));
assertThat(header, hasEntry("HEADER2", "VALUE2"));
}
@Test
public void shouldHaveDefaultValuesForRedirectCachesAndTimeouts() {
final HttpRequest httpRequest = httpDeleteRequest(URL).compile();
assertThat(httpRequest.connectTimeoutMs, is(CONNECT_TIMEOUT_MS)); | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
// Path: extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java
import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
assertThat(httpRequest.method, is("PUT"));
assertThat(httpRequest.url, is(URL));
assertThat(httpRequest.body, is(DATA));
}
@Test
public void shouldCreateHttpDeleteRequest() {
final HttpRequest httpRequest = httpDeleteRequest(URL).compile();
assertThat(httpRequest.method, is("DELETE"));
assertThat(httpRequest.url, is(URL));
}
@Test
public void shouldCreateSetHeaderFields() {
final HttpRequest httpRequest = httpGetRequest(URL)
.headerField("HEADER1", "VALUE1")
.headerField("HEADER2", "VALUE2")
.compile();
final Map<String, String> header = httpRequest.header;
assertThat(header, hasEntry("HEADER1", "VALUE1"));
assertThat(header, hasEntry("HEADER2", "VALUE2"));
}
@Test
public void shouldHaveDefaultValuesForRedirectCachesAndTimeouts() {
final HttpRequest httpRequest = httpDeleteRequest(URL).compile();
assertThat(httpRequest.connectTimeoutMs, is(CONNECT_TIMEOUT_MS)); | assertThat(httpRequest.readTimeoutMs, is(READ_TIMEOUT_MS)); |
google/agera | extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
| import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile; | final HttpRequest httpRequest = httpDeleteRequest(URL).compile();
assertThat(httpRequest.connectTimeoutMs, is(CONNECT_TIMEOUT_MS));
assertThat(httpRequest.readTimeoutMs, is(READ_TIMEOUT_MS));
assertThat(httpRequest.followRedirects, is(true));
assertThat(httpRequest.useCaches, is(true));
}
@Test
public void shouldDisableCaches() {
assertThat(httpDeleteRequest(URL).noCaches().compile().useCaches, is(false));
}
@Test
public void shouldDisableFollowRedirects() {
assertThat(httpDeleteRequest(URL).noRedirects().compile().followRedirects, is(false));
}
@Test
public void shouldSetReadTimeout() {
assertThat(httpDeleteRequest(URL).readTimeoutMs(2).compile().readTimeoutMs, is(2));
}
@Test
public void shouldSetConnectTimeout() {
assertThat(httpDeleteRequest(URL).connectTimeoutMs(3).compile().connectTimeoutMs, is(3));
}
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForReuseOfCompilerOfNoRedirects() { | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
// Path: extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java
import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
final HttpRequest httpRequest = httpDeleteRequest(URL).compile();
assertThat(httpRequest.connectTimeoutMs, is(CONNECT_TIMEOUT_MS));
assertThat(httpRequest.readTimeoutMs, is(READ_TIMEOUT_MS));
assertThat(httpRequest.followRedirects, is(true));
assertThat(httpRequest.useCaches, is(true));
}
@Test
public void shouldDisableCaches() {
assertThat(httpDeleteRequest(URL).noCaches().compile().useCaches, is(false));
}
@Test
public void shouldDisableFollowRedirects() {
assertThat(httpDeleteRequest(URL).noRedirects().compile().followRedirects, is(false));
}
@Test
public void shouldSetReadTimeout() {
assertThat(httpDeleteRequest(URL).readTimeoutMs(2).compile().readTimeoutMs, is(2));
}
@Test
public void shouldSetConnectTimeout() {
assertThat(httpDeleteRequest(URL).connectTimeoutMs(3).compile().connectTimeoutMs, is(3));
}
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForReuseOfCompilerOfNoRedirects() { | final HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile incompleteRequest = |
google/agera | extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
| import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile; |
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForReuseOfCompilerOfReadTimeoutMs() {
final HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile incompleteRequest =
httpGetRequest(URL);
incompleteRequest.compile();
incompleteRequest.readTimeoutMs(1);
}
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForReuseOfCompilerOfCompile() {
final HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile incompleteRequest =
httpGetRequest(URL);
incompleteRequest.compile();
incompleteRequest.compile();
}
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForReuseOfCompilerOfHeaderField() {
final HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile incompleteRequest =
httpGetRequest(URL);
incompleteRequest.compile();
incompleteRequest.headerField("", "");
}
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForReuseOfCompilerOfBody() { | // Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int CONNECT_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompiler.java
// static final int READ_TIMEOUT_MS = 2500;
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpDeleteRequest(@NonNull final String url) {
// return new HttpRequestCompiler("DELETE", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpGetRequest(@NonNull final String url) {
// return new HttpRequestCompiler("GET", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPostRequest(@NonNull final String url) {
// return new HttpRequestCompiler("POST", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequests.java
// @NonNull
// @SuppressWarnings("unchecked")
// public static HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// httpPutRequest(@NonNull final String url) {
// return new HttpRequestCompiler("PUT", url);
// }
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTBody, HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile {}
//
// Path: extensions/net/src/main/java/com/google/android/agera/net/HttpRequestCompilerStates.java
// interface HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile
// extends HTCachesConnectionTimeoutReadTimeoutCompile {
//
// /**
// * Adds a header field to the {@link HttpRequest}.
// */
// @NonNull
// HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile headerField(
// @NonNull String name, @NonNull String value);
//
//
// /**
// * Turns off follow redirects.
// */
// @NonNull
// HTCachesConnectionTimeoutReadTimeoutCompile noRedirects();
// }
// Path: extensions/net/src/test/java/com/google/android/agera/net/HttpRequestTest.java
import com.google.android.agera.net.HttpRequestCompilerStates.HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
import java.util.Map;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static com.google.android.agera.net.HttpRequestCompiler.CONNECT_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequestCompiler.READ_TIMEOUT_MS;
import static com.google.android.agera.net.HttpRequests.httpDeleteRequest;
import static com.google.android.agera.net.HttpRequests.httpGetRequest;
import static com.google.android.agera.net.HttpRequests.httpPostRequest;
import static com.google.android.agera.net.HttpRequests.httpPutRequest;
import static com.google.android.agera.net.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import com.google.android.agera.net.HttpRequestCompilerStates.HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile;
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForReuseOfCompilerOfReadTimeoutMs() {
final HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile incompleteRequest =
httpGetRequest(URL);
incompleteRequest.compile();
incompleteRequest.readTimeoutMs(1);
}
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForReuseOfCompilerOfCompile() {
final HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile incompleteRequest =
httpGetRequest(URL);
incompleteRequest.compile();
incompleteRequest.compile();
}
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForReuseOfCompilerOfHeaderField() {
final HTHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile incompleteRequest =
httpGetRequest(URL);
incompleteRequest.compile();
incompleteRequest.headerField("", "");
}
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionForReuseOfCompilerOfBody() { | final HTBodyHeaderFieldRedirectsCachesConnectionTimeoutReadTimeoutCompile incompleteRequest = |
google/agera | agera/src/main/java/com/google/android/agera/Reservoirs.java | // Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> absentIfNull(@Nullable final T value) {
// return value == null ? Result.<T>absent() : present(value);
// }
| import static com.google.android.agera.Preconditions.checkNotNull;
import static com.google.android.agera.Result.absentIfNull;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.ArrayDeque;
import java.util.PriorityQueue;
import java.util.Queue; |
private SynchronizedReservoir(@NonNull final Queue<T> queue) {
this.queue = checkNotNull(queue);
}
@Override
public void accept(@NonNull T value) {
boolean shouldDispatchUpdate;
synchronized (queue) {
boolean wasEmpty = queue.isEmpty();
boolean added = queue.offer(value);
shouldDispatchUpdate = wasEmpty && added;
}
if (shouldDispatchUpdate) {
dispatchUpdate();
}
}
@NonNull
@Override
public Result<T> get() {
T nullableValue;
boolean shouldDispatchUpdate;
synchronized (queue) {
nullableValue = queue.poll();
shouldDispatchUpdate = !queue.isEmpty();
}
if (shouldDispatchUpdate) {
dispatchUpdate();
} | // Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> absentIfNull(@Nullable final T value) {
// return value == null ? Result.<T>absent() : present(value);
// }
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
import static com.google.android.agera.Preconditions.checkNotNull;
import static com.google.android.agera.Result.absentIfNull;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.ArrayDeque;
import java.util.PriorityQueue;
import java.util.Queue;
private SynchronizedReservoir(@NonNull final Queue<T> queue) {
this.queue = checkNotNull(queue);
}
@Override
public void accept(@NonNull T value) {
boolean shouldDispatchUpdate;
synchronized (queue) {
boolean wasEmpty = queue.isEmpty();
boolean added = queue.offer(value);
shouldDispatchUpdate = wasEmpty && added;
}
if (shouldDispatchUpdate) {
dispatchUpdate();
}
}
@NonNull
@Override
public Result<T> get() {
T nullableValue;
boolean shouldDispatchUpdate;
synchronized (queue) {
nullableValue = queue.poll();
shouldDispatchUpdate = !queue.isEmpty();
}
if (shouldDispatchUpdate) {
dispatchUpdate();
} | return absentIfNull(nullableValue); |
google/agera | extensions/rvadapter/src/test/java/com/google/android/agera/rvadapter/RepositoryAdapterTest.java | // Path: agera/src/main/java/com/google/android/agera/Observables.java
// @NonNull
// public static UpdateDispatcher updateDispatcher() {
// return new AsyncUpdateDispatcher(null);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> MutableRepository<T> mutableRepository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> Repository<T> repository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: extensions/rvadapter/src/main/java/com/google/android/agera/rvadapter/RepositoryAdapter.java
// @NonNull
// public static Builder repositoryAdapter() {
// return new Builder();
// }
| import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static com.google.android.agera.Observables.updateDispatcher;
import static com.google.android.agera.Repositories.mutableRepository;
import static com.google.android.agera.Repositories.repository;
import static com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.robolectric.annotation.Config.NONE;
import static org.robolectric.shadows.ShadowLooper.runUiThreadTasksIncludingDelayedTasks;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.agera.MutableRepository;
import com.google.android.agera.Repository;
import com.google.android.agera.UpdateDispatcher;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; | @Mock
private RepositoryPresenter repositoryPresenter;
@Mock
private RepositoryPresenter secondRepositoryPresenter;
@Mock
private RepositoryPresenter singleItemRepositoryPresenter;
@Mock
private RepositoryPresenter multiItemRepositoryPresenter;
@Mock
private RepositoryPresenter zeroItemRepositoryPresenter;
@Mock
private LayoutPresenter layoutPresenter;
@Mock
private LayoutPresenter secondLayoutPresenter;
@Mock
private ViewHolder viewHolder;
@Mock
private ViewGroup viewGroup;
@Mock
private Context context;
@Mock
private LayoutInflater layoutInflater;
@Mock
private View view;
@Mock
private Activity activity;
@Mock
private Application application;
@Mock
private AdapterDataObserver observer; | // Path: agera/src/main/java/com/google/android/agera/Observables.java
// @NonNull
// public static UpdateDispatcher updateDispatcher() {
// return new AsyncUpdateDispatcher(null);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> MutableRepository<T> mutableRepository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> Repository<T> repository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: extensions/rvadapter/src/main/java/com/google/android/agera/rvadapter/RepositoryAdapter.java
// @NonNull
// public static Builder repositoryAdapter() {
// return new Builder();
// }
// Path: extensions/rvadapter/src/test/java/com/google/android/agera/rvadapter/RepositoryAdapterTest.java
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static com.google.android.agera.Observables.updateDispatcher;
import static com.google.android.agera.Repositories.mutableRepository;
import static com.google.android.agera.Repositories.repository;
import static com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.robolectric.annotation.Config.NONE;
import static org.robolectric.shadows.ShadowLooper.runUiThreadTasksIncludingDelayedTasks;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.agera.MutableRepository;
import com.google.android.agera.Repository;
import com.google.android.agera.UpdateDispatcher;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
@Mock
private RepositoryPresenter repositoryPresenter;
@Mock
private RepositoryPresenter secondRepositoryPresenter;
@Mock
private RepositoryPresenter singleItemRepositoryPresenter;
@Mock
private RepositoryPresenter multiItemRepositoryPresenter;
@Mock
private RepositoryPresenter zeroItemRepositoryPresenter;
@Mock
private LayoutPresenter layoutPresenter;
@Mock
private LayoutPresenter secondLayoutPresenter;
@Mock
private ViewHolder viewHolder;
@Mock
private ViewGroup viewGroup;
@Mock
private Context context;
@Mock
private LayoutInflater layoutInflater;
@Mock
private View view;
@Mock
private Activity activity;
@Mock
private Application application;
@Mock
private AdapterDataObserver observer; | private UpdateDispatcher updateDispatcher; |
google/agera | extensions/rvadapter/src/test/java/com/google/android/agera/rvadapter/RepositoryAdapterTest.java | // Path: agera/src/main/java/com/google/android/agera/Observables.java
// @NonNull
// public static UpdateDispatcher updateDispatcher() {
// return new AsyncUpdateDispatcher(null);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> MutableRepository<T> mutableRepository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> Repository<T> repository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: extensions/rvadapter/src/main/java/com/google/android/agera/rvadapter/RepositoryAdapter.java
// @NonNull
// public static Builder repositoryAdapter() {
// return new Builder();
// }
| import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static com.google.android.agera.Observables.updateDispatcher;
import static com.google.android.agera.Repositories.mutableRepository;
import static com.google.android.agera.Repositories.repository;
import static com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.robolectric.annotation.Config.NONE;
import static org.robolectric.shadows.ShadowLooper.runUiThreadTasksIncludingDelayedTasks;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.agera.MutableRepository;
import com.google.android.agera.Repository;
import com.google.android.agera.UpdateDispatcher;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; | private RepositoryPresenter repositoryPresenter;
@Mock
private RepositoryPresenter secondRepositoryPresenter;
@Mock
private RepositoryPresenter singleItemRepositoryPresenter;
@Mock
private RepositoryPresenter multiItemRepositoryPresenter;
@Mock
private RepositoryPresenter zeroItemRepositoryPresenter;
@Mock
private LayoutPresenter layoutPresenter;
@Mock
private LayoutPresenter secondLayoutPresenter;
@Mock
private ViewHolder viewHolder;
@Mock
private ViewGroup viewGroup;
@Mock
private Context context;
@Mock
private LayoutInflater layoutInflater;
@Mock
private View view;
@Mock
private Activity activity;
@Mock
private Application application;
@Mock
private AdapterDataObserver observer;
private UpdateDispatcher updateDispatcher; | // Path: agera/src/main/java/com/google/android/agera/Observables.java
// @NonNull
// public static UpdateDispatcher updateDispatcher() {
// return new AsyncUpdateDispatcher(null);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> MutableRepository<T> mutableRepository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> Repository<T> repository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: extensions/rvadapter/src/main/java/com/google/android/agera/rvadapter/RepositoryAdapter.java
// @NonNull
// public static Builder repositoryAdapter() {
// return new Builder();
// }
// Path: extensions/rvadapter/src/test/java/com/google/android/agera/rvadapter/RepositoryAdapterTest.java
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static com.google.android.agera.Observables.updateDispatcher;
import static com.google.android.agera.Repositories.mutableRepository;
import static com.google.android.agera.Repositories.repository;
import static com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.robolectric.annotation.Config.NONE;
import static org.robolectric.shadows.ShadowLooper.runUiThreadTasksIncludingDelayedTasks;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.agera.MutableRepository;
import com.google.android.agera.Repository;
import com.google.android.agera.UpdateDispatcher;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
private RepositoryPresenter repositoryPresenter;
@Mock
private RepositoryPresenter secondRepositoryPresenter;
@Mock
private RepositoryPresenter singleItemRepositoryPresenter;
@Mock
private RepositoryPresenter multiItemRepositoryPresenter;
@Mock
private RepositoryPresenter zeroItemRepositoryPresenter;
@Mock
private LayoutPresenter layoutPresenter;
@Mock
private LayoutPresenter secondLayoutPresenter;
@Mock
private ViewHolder viewHolder;
@Mock
private ViewGroup viewGroup;
@Mock
private Context context;
@Mock
private LayoutInflater layoutInflater;
@Mock
private View view;
@Mock
private Activity activity;
@Mock
private Application application;
@Mock
private AdapterDataObserver observer;
private UpdateDispatcher updateDispatcher; | private MutableRepository repository; |
google/agera | extensions/rvadapter/src/test/java/com/google/android/agera/rvadapter/RepositoryAdapterTest.java | // Path: agera/src/main/java/com/google/android/agera/Observables.java
// @NonNull
// public static UpdateDispatcher updateDispatcher() {
// return new AsyncUpdateDispatcher(null);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> MutableRepository<T> mutableRepository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> Repository<T> repository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: extensions/rvadapter/src/main/java/com/google/android/agera/rvadapter/RepositoryAdapter.java
// @NonNull
// public static Builder repositoryAdapter() {
// return new Builder();
// }
| import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static com.google.android.agera.Observables.updateDispatcher;
import static com.google.android.agera.Repositories.mutableRepository;
import static com.google.android.agera.Repositories.repository;
import static com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.robolectric.annotation.Config.NONE;
import static org.robolectric.shadows.ShadowLooper.runUiThreadTasksIncludingDelayedTasks;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.agera.MutableRepository;
import com.google.android.agera.Repository;
import com.google.android.agera.UpdateDispatcher;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; | private RepositoryPresenter secondRepositoryPresenter;
@Mock
private RepositoryPresenter singleItemRepositoryPresenter;
@Mock
private RepositoryPresenter multiItemRepositoryPresenter;
@Mock
private RepositoryPresenter zeroItemRepositoryPresenter;
@Mock
private LayoutPresenter layoutPresenter;
@Mock
private LayoutPresenter secondLayoutPresenter;
@Mock
private ViewHolder viewHolder;
@Mock
private ViewGroup viewGroup;
@Mock
private Context context;
@Mock
private LayoutInflater layoutInflater;
@Mock
private View view;
@Mock
private Activity activity;
@Mock
private Application application;
@Mock
private AdapterDataObserver observer;
private UpdateDispatcher updateDispatcher;
private MutableRepository repository;
private Repository secondRepository; | // Path: agera/src/main/java/com/google/android/agera/Observables.java
// @NonNull
// public static UpdateDispatcher updateDispatcher() {
// return new AsyncUpdateDispatcher(null);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> MutableRepository<T> mutableRepository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> Repository<T> repository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: extensions/rvadapter/src/main/java/com/google/android/agera/rvadapter/RepositoryAdapter.java
// @NonNull
// public static Builder repositoryAdapter() {
// return new Builder();
// }
// Path: extensions/rvadapter/src/test/java/com/google/android/agera/rvadapter/RepositoryAdapterTest.java
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static com.google.android.agera.Observables.updateDispatcher;
import static com.google.android.agera.Repositories.mutableRepository;
import static com.google.android.agera.Repositories.repository;
import static com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.robolectric.annotation.Config.NONE;
import static org.robolectric.shadows.ShadowLooper.runUiThreadTasksIncludingDelayedTasks;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.agera.MutableRepository;
import com.google.android.agera.Repository;
import com.google.android.agera.UpdateDispatcher;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
private RepositoryPresenter secondRepositoryPresenter;
@Mock
private RepositoryPresenter singleItemRepositoryPresenter;
@Mock
private RepositoryPresenter multiItemRepositoryPresenter;
@Mock
private RepositoryPresenter zeroItemRepositoryPresenter;
@Mock
private LayoutPresenter layoutPresenter;
@Mock
private LayoutPresenter secondLayoutPresenter;
@Mock
private ViewHolder viewHolder;
@Mock
private ViewGroup viewGroup;
@Mock
private Context context;
@Mock
private LayoutInflater layoutInflater;
@Mock
private View view;
@Mock
private Activity activity;
@Mock
private Application application;
@Mock
private AdapterDataObserver observer;
private UpdateDispatcher updateDispatcher;
private MutableRepository repository;
private Repository secondRepository; | private RepositoryAdapter repositoryAdapter; |
google/agera | extensions/rvadapter/src/test/java/com/google/android/agera/rvadapter/RepositoryAdapterTest.java | // Path: agera/src/main/java/com/google/android/agera/Observables.java
// @NonNull
// public static UpdateDispatcher updateDispatcher() {
// return new AsyncUpdateDispatcher(null);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> MutableRepository<T> mutableRepository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> Repository<T> repository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: extensions/rvadapter/src/main/java/com/google/android/agera/rvadapter/RepositoryAdapter.java
// @NonNull
// public static Builder repositoryAdapter() {
// return new Builder();
// }
| import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static com.google.android.agera.Observables.updateDispatcher;
import static com.google.android.agera.Repositories.mutableRepository;
import static com.google.android.agera.Repositories.repository;
import static com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.robolectric.annotation.Config.NONE;
import static org.robolectric.shadows.ShadowLooper.runUiThreadTasksIncludingDelayedTasks;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.agera.MutableRepository;
import com.google.android.agera.Repository;
import com.google.android.agera.UpdateDispatcher;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; | @Mock
private LayoutPresenter secondLayoutPresenter;
@Mock
private ViewHolder viewHolder;
@Mock
private ViewGroup viewGroup;
@Mock
private Context context;
@Mock
private LayoutInflater layoutInflater;
@Mock
private View view;
@Mock
private Activity activity;
@Mock
private Application application;
@Mock
private AdapterDataObserver observer;
private UpdateDispatcher updateDispatcher;
private MutableRepository repository;
private Repository secondRepository;
private RepositoryAdapter repositoryAdapter;
private RepositoryAdapter repositoryAdapterWithoutStatic;
private Adapter repositoryAdapterWhileResumed;
private Adapter repositoryAdapterWhileStarted;
@Before
public void setUp() {
initMocks(this);
updateDispatcher = updateDispatcher(); | // Path: agera/src/main/java/com/google/android/agera/Observables.java
// @NonNull
// public static UpdateDispatcher updateDispatcher() {
// return new AsyncUpdateDispatcher(null);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> MutableRepository<T> mutableRepository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> Repository<T> repository(@NonNull final T object) {
// return new SimpleRepository<>(object);
// }
//
// Path: extensions/rvadapter/src/main/java/com/google/android/agera/rvadapter/RepositoryAdapter.java
// @NonNull
// public static Builder repositoryAdapter() {
// return new Builder();
// }
// Path: extensions/rvadapter/src/test/java/com/google/android/agera/rvadapter/RepositoryAdapterTest.java
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static com.google.android.agera.Observables.updateDispatcher;
import static com.google.android.agera.Repositories.mutableRepository;
import static com.google.android.agera.Repositories.repository;
import static com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentCaptor.forClass;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.robolectric.annotation.Config.NONE;
import static org.robolectric.shadows.ShadowLooper.runUiThreadTasksIncludingDelayedTasks;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.agera.MutableRepository;
import com.google.android.agera.Repository;
import com.google.android.agera.UpdateDispatcher;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
@Mock
private LayoutPresenter secondLayoutPresenter;
@Mock
private ViewHolder viewHolder;
@Mock
private ViewGroup viewGroup;
@Mock
private Context context;
@Mock
private LayoutInflater layoutInflater;
@Mock
private View view;
@Mock
private Activity activity;
@Mock
private Application application;
@Mock
private AdapterDataObserver observer;
private UpdateDispatcher updateDispatcher;
private MutableRepository repository;
private Repository secondRepository;
private RepositoryAdapter repositoryAdapter;
private RepositoryAdapter repositoryAdapterWithoutStatic;
private Adapter repositoryAdapterWhileResumed;
private Adapter repositoryAdapterWhileStarted;
@Before
public void setUp() {
initMocks(this);
updateDispatcher = updateDispatcher(); | repository = mutableRepository(REPOSITORY_ITEM); |
google/agera | agera/src/main/java/com/google/android/agera/Common.java | // Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
| import static com.google.android.agera.Preconditions.checkNotNull;
import static com.google.android.agera.Result.failure;
import android.support.annotation.NonNull; | @NonNull
private final TTo staticValue;
StaticProducer(@NonNull final TTo staticValue) {
this.staticValue = checkNotNull(staticValue);
}
@NonNull
@Override
public TTo apply(@NonNull final TFirst input) {
return staticValue;
}
@NonNull
@Override
public TTo merge(@NonNull final TFirst o, @NonNull final TSecond o2) {
return staticValue;
}
@NonNull
@Override
public TTo get() {
return staticValue;
}
}
private static final class FailedResult<T> implements Function<Throwable, Result<T>> {
@NonNull
@Override
public Result<T> apply(@NonNull final Throwable input) { | // Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
// Path: agera/src/main/java/com/google/android/agera/Common.java
import static com.google.android.agera.Preconditions.checkNotNull;
import static com.google.android.agera.Result.failure;
import android.support.annotation.NonNull;
@NonNull
private final TTo staticValue;
StaticProducer(@NonNull final TTo staticValue) {
this.staticValue = checkNotNull(staticValue);
}
@NonNull
@Override
public TTo apply(@NonNull final TFirst input) {
return staticValue;
}
@NonNull
@Override
public TTo merge(@NonNull final TFirst o, @NonNull final TSecond o2) {
return staticValue;
}
@NonNull
@Override
public TTo get() {
return staticValue;
}
}
private static final class FailedResult<T> implements Function<Throwable, Result<T>> {
@NonNull
@Override
public Result<T> apply(@NonNull final Throwable input) { | return failure(input); |
google/agera | agera/src/test/java/com/google/android/agera/FunctionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class FunctionsTest {
private static final int VALUE = 42;
private static final int VALUE_PLUS_TWO = 44;
private static final int RECOVER_VALUE = 43;
private static final String INPUT_STRING = "input";
private static final List<String> INPUT_LIST = asList("some", "strings", "for", "testing");
@SuppressWarnings("ThrowableInstanceNeverThrown")
private static final Throwable THROWABLE = new Throwable(); | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class FunctionsTest {
private static final int VALUE = 42;
private static final int VALUE_PLUS_TWO = 44;
private static final int RECOVER_VALUE = 43;
private static final String INPUT_STRING = "input";
private static final List<String> INPUT_LIST = asList("some", "strings", "for", "testing");
@SuppressWarnings("ThrowableInstanceNeverThrown")
private static final Throwable THROWABLE = new Throwable(); | private static final Result<Integer> FAILURE = failure(THROWABLE); |
google/agera | agera/src/test/java/com/google/android/agera/FunctionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class FunctionsTest {
private static final int VALUE = 42;
private static final int VALUE_PLUS_TWO = 44;
private static final int RECOVER_VALUE = 43;
private static final String INPUT_STRING = "input";
private static final List<String> INPUT_LIST = asList("some", "strings", "for", "testing");
@SuppressWarnings("ThrowableInstanceNeverThrown")
private static final Throwable THROWABLE = new Throwable();
private static final Result<Integer> FAILURE = failure(THROWABLE); | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class FunctionsTest {
private static final int VALUE = 42;
private static final int VALUE_PLUS_TWO = 44;
private static final int RECOVER_VALUE = 43;
private static final String INPUT_STRING = "input";
private static final List<String> INPUT_LIST = asList("some", "strings", "for", "testing");
@SuppressWarnings("ThrowableInstanceNeverThrown")
private static final Throwable THROWABLE = new Throwable();
private static final Result<Integer> FAILURE = failure(THROWABLE); | private static final Result<Integer> RECOVER_SUCCESS = success(RECOVER_VALUE); |
google/agera | agera/src/test/java/com/google/android/agera/FunctionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class FunctionsTest {
private static final int VALUE = 42;
private static final int VALUE_PLUS_TWO = 44;
private static final int RECOVER_VALUE = 43;
private static final String INPUT_STRING = "input";
private static final List<String> INPUT_LIST = asList("some", "strings", "for", "testing");
@SuppressWarnings("ThrowableInstanceNeverThrown")
private static final Throwable THROWABLE = new Throwable();
private static final Result<Integer> FAILURE = failure(THROWABLE);
private static final Result<Integer> RECOVER_SUCCESS = success(RECOVER_VALUE); | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class FunctionsTest {
private static final int VALUE = 42;
private static final int VALUE_PLUS_TWO = 44;
private static final int RECOVER_VALUE = 43;
private static final String INPUT_STRING = "input";
private static final List<String> INPUT_LIST = asList("some", "strings", "for", "testing");
@SuppressWarnings("ThrowableInstanceNeverThrown")
private static final Throwable THROWABLE = new Throwable();
private static final Result<Integer> FAILURE = failure(THROWABLE);
private static final Result<Integer> RECOVER_SUCCESS = success(RECOVER_VALUE); | private static final Result<Integer> PRESENT_WITH_VALUE = present(VALUE); |
google/agera | agera/src/test/java/com/google/android/agera/FunctionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class FunctionsTest {
private static final int VALUE = 42;
private static final int VALUE_PLUS_TWO = 44;
private static final int RECOVER_VALUE = 43;
private static final String INPUT_STRING = "input";
private static final List<String> INPUT_LIST = asList("some", "strings", "for", "testing");
@SuppressWarnings("ThrowableInstanceNeverThrown")
private static final Throwable THROWABLE = new Throwable();
private static final Result<Integer> FAILURE = failure(THROWABLE);
private static final Result<Integer> RECOVER_SUCCESS = success(RECOVER_VALUE);
private static final Result<Integer> PRESENT_WITH_VALUE = present(VALUE); | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
public final class FunctionsTest {
private static final int VALUE = 42;
private static final int VALUE_PLUS_TWO = 44;
private static final int RECOVER_VALUE = 43;
private static final String INPUT_STRING = "input";
private static final List<String> INPUT_LIST = asList("some", "strings", "for", "testing");
@SuppressWarnings("ThrowableInstanceNeverThrown")
private static final Throwable THROWABLE = new Throwable();
private static final Result<Integer> FAILURE = failure(THROWABLE);
private static final Result<Integer> RECOVER_SUCCESS = success(RECOVER_VALUE);
private static final Result<Integer> PRESENT_WITH_VALUE = present(VALUE); | private static final Result<Integer> ABSENT = absent(); |
google/agera | agera/src/test/java/com/google/android/agera/FunctionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | private static final Result<List<Integer>> FAILURE_LIST = failure(THROWABLE);
private static final Result<List<Integer>> ABSENT_LIST = absent();
private static final Result<List<String>> PRESENT_WITH_LIST = present(INPUT_LIST);
@Mock
private Function<Integer, Result<Integer>> mockDivideTenFunction;
@Mock
private Function<Integer, Integer> mockPlusTwoFunction;
@Mock
private Function<Throwable, Result<Integer>> mockTryRecoverFunction;
@Mock
private Function<Throwable, Integer> mockRecoverFunction;
@Mock
private Supplier<String> mockSupplier;
@Before
public void setup() {
initMocks(this);
when(mockRecoverFunction.apply(THROWABLE)).thenReturn(RECOVER_VALUE);
when(mockTryRecoverFunction.apply(THROWABLE)).thenReturn(RECOVER_SUCCESS);
when(mockPlusTwoFunction.apply(anyInt())).thenReturn(VALUE_PLUS_TWO);
when(mockDivideTenFunction.apply(eq(2))).thenReturn(success(5));
when(mockDivideTenFunction.apply(eq(0))).thenReturn(FAILURE);
when(mockSupplier.get()).thenReturn(INPUT_STRING);
}
@Test
public void shouldWrapThrowableInFailedResult() {
final Throwable throwable = new Throwable();
| // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
private static final Result<List<Integer>> FAILURE_LIST = failure(THROWABLE);
private static final Result<List<Integer>> ABSENT_LIST = absent();
private static final Result<List<String>> PRESENT_WITH_LIST = present(INPUT_LIST);
@Mock
private Function<Integer, Result<Integer>> mockDivideTenFunction;
@Mock
private Function<Integer, Integer> mockPlusTwoFunction;
@Mock
private Function<Throwable, Result<Integer>> mockTryRecoverFunction;
@Mock
private Function<Throwable, Integer> mockRecoverFunction;
@Mock
private Supplier<String> mockSupplier;
@Before
public void setup() {
initMocks(this);
when(mockRecoverFunction.apply(THROWABLE)).thenReturn(RECOVER_VALUE);
when(mockTryRecoverFunction.apply(THROWABLE)).thenReturn(RECOVER_SUCCESS);
when(mockPlusTwoFunction.apply(anyInt())).thenReturn(VALUE_PLUS_TWO);
when(mockDivideTenFunction.apply(eq(2))).thenReturn(success(5));
when(mockDivideTenFunction.apply(eq(0))).thenReturn(FAILURE);
when(mockSupplier.get()).thenReturn(INPUT_STRING);
}
@Test
public void shouldWrapThrowableInFailedResult() {
final Throwable throwable = new Throwable();
| assertThat(failedResult().apply(throwable).getFailure(), is(throwable)); |
google/agera | agera/src/test/java/com/google/android/agera/FunctionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | assertThat(Functions.<Integer>resultAsList().apply(FAILURE), is((empty())));
}
@Test
public void shouldReturnFunctionReturningListWithValueForPresentWithValue() {
assertThat(Functions.<Integer>resultAsList().apply(PRESENT_WITH_VALUE), contains(VALUE));
}
@Test
public void shouldFunctionReturningEmptyListForAbsentList() {
assertThat(Functions.<Integer>resultListAsList().apply(ABSENT_LIST), is((empty())));
}
@Test
public void shouldReturnFunctionReturingEmptyListForFailureList() {
assertThat(Functions.<Integer>resultListAsList().apply(FAILURE_LIST), is((empty())));
}
@Test
public void shouldReturnFunctionReturningListWithValueForPresentWithList() {
assertThat(Functions.<String>resultListAsList().apply(PRESENT_WITH_LIST), is(INPUT_LIST));
}
@Test
public void shouldReturnFunctionReturningListWithValue() {
assertThat(Functions.<Integer>itemAsList().apply(VALUE), contains(VALUE));
}
@Test
public void shouldReturnObjectFromStaticFunction() { | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
assertThat(Functions.<Integer>resultAsList().apply(FAILURE), is((empty())));
}
@Test
public void shouldReturnFunctionReturningListWithValueForPresentWithValue() {
assertThat(Functions.<Integer>resultAsList().apply(PRESENT_WITH_VALUE), contains(VALUE));
}
@Test
public void shouldFunctionReturningEmptyListForAbsentList() {
assertThat(Functions.<Integer>resultListAsList().apply(ABSENT_LIST), is((empty())));
}
@Test
public void shouldReturnFunctionReturingEmptyListForFailureList() {
assertThat(Functions.<Integer>resultListAsList().apply(FAILURE_LIST), is((empty())));
}
@Test
public void shouldReturnFunctionReturningListWithValueForPresentWithList() {
assertThat(Functions.<String>resultListAsList().apply(PRESENT_WITH_LIST), is(INPUT_LIST));
}
@Test
public void shouldReturnFunctionReturningListWithValue() {
assertThat(Functions.<Integer>itemAsList().apply(VALUE), contains(VALUE));
}
@Test
public void shouldReturnObjectFromStaticFunction() { | assertThat(staticFunction(INPUT_STRING).apply(new Object()), is(sameInstance(INPUT_STRING))); |
google/agera | agera/src/test/java/com/google/android/agera/FunctionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | assertThat(Functions.<Integer>resultAsList().apply(PRESENT_WITH_VALUE), contains(VALUE));
}
@Test
public void shouldFunctionReturningEmptyListForAbsentList() {
assertThat(Functions.<Integer>resultListAsList().apply(ABSENT_LIST), is((empty())));
}
@Test
public void shouldReturnFunctionReturingEmptyListForFailureList() {
assertThat(Functions.<Integer>resultListAsList().apply(FAILURE_LIST), is((empty())));
}
@Test
public void shouldReturnFunctionReturningListWithValueForPresentWithList() {
assertThat(Functions.<String>resultListAsList().apply(PRESENT_WITH_LIST), is(INPUT_LIST));
}
@Test
public void shouldReturnFunctionReturningListWithValue() {
assertThat(Functions.<Integer>itemAsList().apply(VALUE), contains(VALUE));
}
@Test
public void shouldReturnObjectFromStaticFunction() {
assertThat(staticFunction(INPUT_STRING).apply(new Object()), is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnObjectFromSupplierForSupplierAsFunction() { | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
assertThat(Functions.<Integer>resultAsList().apply(PRESENT_WITH_VALUE), contains(VALUE));
}
@Test
public void shouldFunctionReturningEmptyListForAbsentList() {
assertThat(Functions.<Integer>resultListAsList().apply(ABSENT_LIST), is((empty())));
}
@Test
public void shouldReturnFunctionReturingEmptyListForFailureList() {
assertThat(Functions.<Integer>resultListAsList().apply(FAILURE_LIST), is((empty())));
}
@Test
public void shouldReturnFunctionReturningListWithValueForPresentWithList() {
assertThat(Functions.<String>resultListAsList().apply(PRESENT_WITH_LIST), is(INPUT_LIST));
}
@Test
public void shouldReturnFunctionReturningListWithValue() {
assertThat(Functions.<Integer>itemAsList().apply(VALUE), contains(VALUE));
}
@Test
public void shouldReturnObjectFromStaticFunction() {
assertThat(staticFunction(INPUT_STRING).apply(new Object()), is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnObjectFromSupplierForSupplierAsFunction() { | assertThat(supplierAsFunction(mockSupplier).apply(new Object()), |
google/agera | agera/src/test/java/com/google/android/agera/FunctionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; | }
@Test
public void shouldReturnFunctionReturingEmptyListForFailureList() {
assertThat(Functions.<Integer>resultListAsList().apply(FAILURE_LIST), is((empty())));
}
@Test
public void shouldReturnFunctionReturningListWithValueForPresentWithList() {
assertThat(Functions.<String>resultListAsList().apply(PRESENT_WITH_LIST), is(INPUT_LIST));
}
@Test
public void shouldReturnFunctionReturningListWithValue() {
assertThat(Functions.<Integer>itemAsList().apply(VALUE), contains(VALUE));
}
@Test
public void shouldReturnObjectFromStaticFunction() {
assertThat(staticFunction(INPUT_STRING).apply(new Object()), is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnObjectFromSupplierForSupplierAsFunction() {
assertThat(supplierAsFunction(mockSupplier).apply(new Object()),
is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnFromObject() { | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
}
@Test
public void shouldReturnFunctionReturingEmptyListForFailureList() {
assertThat(Functions.<Integer>resultListAsList().apply(FAILURE_LIST), is((empty())));
}
@Test
public void shouldReturnFunctionReturningListWithValueForPresentWithList() {
assertThat(Functions.<String>resultListAsList().apply(PRESENT_WITH_LIST), is(INPUT_LIST));
}
@Test
public void shouldReturnFunctionReturningListWithValue() {
assertThat(Functions.<Integer>itemAsList().apply(VALUE), contains(VALUE));
}
@Test
public void shouldReturnObjectFromStaticFunction() {
assertThat(staticFunction(INPUT_STRING).apply(new Object()), is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnObjectFromSupplierForSupplierAsFunction() {
assertThat(supplierAsFunction(mockSupplier).apply(new Object()),
is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnFromObject() { | assertThat(Functions.<String>identityFunction().apply(INPUT_STRING), |
google/agera | agera/src/test/java/com/google/android/agera/FunctionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; |
@Test
public void shouldReturnFunctionReturningListWithValue() {
assertThat(Functions.<Integer>itemAsList().apply(VALUE), contains(VALUE));
}
@Test
public void shouldReturnObjectFromStaticFunction() {
assertThat(staticFunction(INPUT_STRING).apply(new Object()), is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnObjectFromSupplierForSupplierAsFunction() {
assertThat(supplierAsFunction(mockSupplier).apply(new Object()),
is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnFromObject() {
assertThat(Functions.<String>identityFunction().apply(INPUT_STRING),
is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldBeASingleton() {
assertThat(identityFunction(), is(sameInstance(identityFunction())));
}
@Test
public void shouldHavePrivateConstructor() { | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@Test
public void shouldReturnFunctionReturningListWithValue() {
assertThat(Functions.<Integer>itemAsList().apply(VALUE), contains(VALUE));
}
@Test
public void shouldReturnObjectFromStaticFunction() {
assertThat(staticFunction(INPUT_STRING).apply(new Object()), is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnObjectFromSupplierForSupplierAsFunction() {
assertThat(supplierAsFunction(mockSupplier).apply(new Object()),
is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnFromObject() {
assertThat(Functions.<String>identityFunction().apply(INPUT_STRING),
is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldBeASingleton() {
assertThat(identityFunction(), is(sameInstance(identityFunction())));
}
@Test
public void shouldHavePrivateConstructor() { | assertThat(Functions.class, hasPrivateConstructor()); |
google/agera | agera/src/test/java/com/google/android/agera/FunctionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; |
@Test
public void shouldReturnObjectFromStaticFunction() {
assertThat(staticFunction(INPUT_STRING).apply(new Object()), is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnObjectFromSupplierForSupplierAsFunction() {
assertThat(supplierAsFunction(mockSupplier).apply(new Object()),
is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnFromObject() {
assertThat(Functions.<String>identityFunction().apply(INPUT_STRING),
is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldBeASingleton() {
assertThat(identityFunction(), is(sameInstance(identityFunction())));
}
@Test
public void shouldHavePrivateConstructor() {
assertThat(Functions.class, hasPrivateConstructor());
}
@Test
public void shouldCreateFunctionFromItemToItem() { | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@Test
public void shouldReturnObjectFromStaticFunction() {
assertThat(staticFunction(INPUT_STRING).apply(new Object()), is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnObjectFromSupplierForSupplierAsFunction() {
assertThat(supplierAsFunction(mockSupplier).apply(new Object()),
is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldReturnFromObject() {
assertThat(Functions.<String>identityFunction().apply(INPUT_STRING),
is(sameInstance(INPUT_STRING)));
}
@Test
public void shouldBeASingleton() {
assertThat(identityFunction(), is(sameInstance(identityFunction())));
}
@Test
public void shouldHavePrivateConstructor() {
assertThat(Functions.class, hasPrivateConstructor());
}
@Test
public void shouldCreateFunctionFromItemToItem() { | final Function<String, Integer> function = functionFrom(String.class) |
google/agera | agera/src/test/java/com/google/android/agera/FunctionsTest.java | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
| import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock; |
@Test
public void shouldHavePrivateConstructor() {
assertThat(Functions.class, hasPrivateConstructor());
}
@Test
public void shouldCreateFunctionFromItemToItem() {
final Function<String, Integer> function = functionFrom(String.class)
.apply(new DoubleString())
.thenApply(new StringLength());
assertThat(function.apply(INPUT_STRING), is(10));
}
@Test
public void shouldCreateFunctionFromItemToItemViaList() {
final Function<String, String> function = functionFrom(String.class)
.apply(new DoubleString())
.unpack(new StringToListChar())
.morph(new SortList<Character>())
.limit(5)
.filter(new CharacterFilter('n'))
.thenApply(new CharacterListToString());
assertThat(function.apply(INPUT_STRING), is("nn"));
}
@Test
public void shouldCreateFunctionFromListToItem() { | // Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
// return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
// @Nullable final Class<F> from) {
// return functionCompiler();
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
// @SuppressWarnings("unchecked")
// final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
// return identityFunction;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
// return new StaticProducer<>(object);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
// @NonNull final Supplier<? extends T> supplier) {
// return new SupplierAsFunction<>(supplier);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
// return (Result<T>) ABSENT;
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
// return failure == ABSENT_THROWABLE
// ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
// return success(value);
// }
//
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
// return new Result<>(checkNotNull(value), null);
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@Test
public void shouldHavePrivateConstructor() {
assertThat(Functions.class, hasPrivateConstructor());
}
@Test
public void shouldCreateFunctionFromItemToItem() {
final Function<String, Integer> function = functionFrom(String.class)
.apply(new DoubleString())
.thenApply(new StringLength());
assertThat(function.apply(INPUT_STRING), is(10));
}
@Test
public void shouldCreateFunctionFromItemToItemViaList() {
final Function<String, String> function = functionFrom(String.class)
.apply(new DoubleString())
.unpack(new StringToListChar())
.morph(new SortList<Character>())
.limit(5)
.filter(new CharacterFilter('n'))
.thenApply(new CharacterListToString());
assertThat(function.apply(INPUT_STRING), is("nn"));
}
@Test
public void shouldCreateFunctionFromListToItem() { | final Function<List<String>, Integer> function = functionFromListOf(String.class) |
google/agera | agera/src/test/java/com/google/android/agera/ReservoirsTest.java | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
| import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
@Config(manifest = NONE)
@RunWith(RobolectricTestRunner.class)
public final class ReservoirsTest {
private static final String STRING_A = "STRING_A";
private static final String STRING_B = "STRING_B";
private static final Integer INTEGER_1 = 1;
private static final Integer INTEGER_2 = 2;
private MockQueue mockQueue;
private Reservoir<String> stringReservoir;
private Reservoir<Integer> integerReservoir;
private Reservoir<Object> customQueueReservoir; | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
// Path: agera/src/test/java/com/google/android/agera/ReservoirsTest.java
import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
@Config(manifest = NONE)
@RunWith(RobolectricTestRunner.class)
public final class ReservoirsTest {
private static final String STRING_A = "STRING_A";
private static final String STRING_B = "STRING_B";
private static final Integer INTEGER_1 = 1;
private static final Integer INTEGER_2 = 2;
private MockQueue mockQueue;
private Reservoir<String> stringReservoir;
private Reservoir<Integer> integerReservoir;
private Reservoir<Object> customQueueReservoir; | private MockUpdatable updatable; |
google/agera | agera/src/test/java/com/google/android/agera/ReservoirsTest.java | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
| import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
@Config(manifest = NONE)
@RunWith(RobolectricTestRunner.class)
public final class ReservoirsTest {
private static final String STRING_A = "STRING_A";
private static final String STRING_B = "STRING_B";
private static final Integer INTEGER_1 = 1;
private static final Integer INTEGER_2 = 2;
private MockQueue mockQueue;
private Reservoir<String> stringReservoir;
private Reservoir<Integer> integerReservoir;
private Reservoir<Object> customQueueReservoir;
private MockUpdatable updatable;
private MockUpdatable anotherUpdatable;
@Before
public void setUp() {
mockQueue = new MockQueue(); | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
// Path: agera/src/test/java/com/google/android/agera/ReservoirsTest.java
import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
@Config(manifest = NONE)
@RunWith(RobolectricTestRunner.class)
public final class ReservoirsTest {
private static final String STRING_A = "STRING_A";
private static final String STRING_B = "STRING_B";
private static final Integer INTEGER_1 = 1;
private static final Integer INTEGER_2 = 2;
private MockQueue mockQueue;
private Reservoir<String> stringReservoir;
private Reservoir<Integer> integerReservoir;
private Reservoir<Object> customQueueReservoir;
private MockUpdatable updatable;
private MockUpdatable anotherUpdatable;
@Before
public void setUp() {
mockQueue = new MockQueue(); | stringReservoir = reservoirOf(String.class); |
google/agera | agera/src/test/java/com/google/android/agera/ReservoirsTest.java | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
| import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
@Config(manifest = NONE)
@RunWith(RobolectricTestRunner.class)
public final class ReservoirsTest {
private static final String STRING_A = "STRING_A";
private static final String STRING_B = "STRING_B";
private static final Integer INTEGER_1 = 1;
private static final Integer INTEGER_2 = 2;
private MockQueue mockQueue;
private Reservoir<String> stringReservoir;
private Reservoir<Integer> integerReservoir;
private Reservoir<Object> customQueueReservoir;
private MockUpdatable updatable;
private MockUpdatable anotherUpdatable;
@Before
public void setUp() {
mockQueue = new MockQueue();
stringReservoir = reservoirOf(String.class); | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
// Path: agera/src/test/java/com/google/android/agera/ReservoirsTest.java
import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
@Config(manifest = NONE)
@RunWith(RobolectricTestRunner.class)
public final class ReservoirsTest {
private static final String STRING_A = "STRING_A";
private static final String STRING_B = "STRING_B";
private static final Integer INTEGER_1 = 1;
private static final Integer INTEGER_2 = 2;
private MockQueue mockQueue;
private Reservoir<String> stringReservoir;
private Reservoir<Integer> integerReservoir;
private Reservoir<Object> customQueueReservoir;
private MockUpdatable updatable;
private MockUpdatable anotherUpdatable;
@Before
public void setUp() {
mockQueue = new MockQueue();
stringReservoir = reservoirOf(String.class); | integerReservoir = reservoir(); |
google/agera | agera/src/test/java/com/google/android/agera/ReservoirsTest.java | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
| import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; | /*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
@Config(manifest = NONE)
@RunWith(RobolectricTestRunner.class)
public final class ReservoirsTest {
private static final String STRING_A = "STRING_A";
private static final String STRING_B = "STRING_B";
private static final Integer INTEGER_1 = 1;
private static final Integer INTEGER_2 = 2;
private MockQueue mockQueue;
private Reservoir<String> stringReservoir;
private Reservoir<Integer> integerReservoir;
private Reservoir<Object> customQueueReservoir;
private MockUpdatable updatable;
private MockUpdatable anotherUpdatable;
@Before
public void setUp() {
mockQueue = new MockQueue();
stringReservoir = reservoirOf(String.class);
integerReservoir = reservoir();
customQueueReservoir = reservoir(mockQueue); | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
// Path: agera/src/test/java/com/google/android/agera/ReservoirsTest.java
import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.agera;
@Config(manifest = NONE)
@RunWith(RobolectricTestRunner.class)
public final class ReservoirsTest {
private static final String STRING_A = "STRING_A";
private static final String STRING_B = "STRING_B";
private static final Integer INTEGER_1 = 1;
private static final Integer INTEGER_2 = 2;
private MockQueue mockQueue;
private Reservoir<String> stringReservoir;
private Reservoir<Integer> integerReservoir;
private Reservoir<Object> customQueueReservoir;
private MockUpdatable updatable;
private MockUpdatable anotherUpdatable;
@Before
public void setUp() {
mockQueue = new MockQueue();
stringReservoir = reservoirOf(String.class);
integerReservoir = reservoir();
customQueueReservoir = reservoir(mockQueue); | updatable = mockUpdatable(); |
google/agera | agera/src/test/java/com/google/android/agera/ReservoirsTest.java | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
| import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; |
@After
public void tearDown() {
updatable.removeFromObservables();
anotherUpdatable.removeFromObservables();
}
@Test
public void shouldGiveAbsentValueFromEmptyReservoir() throws Exception {
assertThat(integerReservoir, givesAbsentValueOf(Integer.class));
}
@Test
public void shouldQueueValues() throws Exception {
stringReservoir.accept(STRING_A);
stringReservoir.accept(STRING_A);
stringReservoir.accept(STRING_B);
stringReservoir.accept(STRING_B);
assertThat(stringReservoir, givesPresentValue(STRING_A));
assertThat(stringReservoir, givesPresentValue(STRING_A));
assertThat(stringReservoir, givesPresentValue(STRING_B));
assertThat(stringReservoir, givesPresentValue(STRING_B));
assertThat(stringReservoir, givesAbsentValueOf(String.class));
}
@Test
public void shouldNotGetUpdateFromEmptyReservoir() throws Exception {
updatable.addToObservable(stringReservoir);
| // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
// Path: agera/src/test/java/com/google/android/agera/ReservoirsTest.java
import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
@After
public void tearDown() {
updatable.removeFromObservables();
anotherUpdatable.removeFromObservables();
}
@Test
public void shouldGiveAbsentValueFromEmptyReservoir() throws Exception {
assertThat(integerReservoir, givesAbsentValueOf(Integer.class));
}
@Test
public void shouldQueueValues() throws Exception {
stringReservoir.accept(STRING_A);
stringReservoir.accept(STRING_A);
stringReservoir.accept(STRING_B);
stringReservoir.accept(STRING_B);
assertThat(stringReservoir, givesPresentValue(STRING_A));
assertThat(stringReservoir, givesPresentValue(STRING_A));
assertThat(stringReservoir, givesPresentValue(STRING_B));
assertThat(stringReservoir, givesPresentValue(STRING_B));
assertThat(stringReservoir, givesAbsentValueOf(String.class));
}
@Test
public void shouldNotGetUpdateFromEmptyReservoir() throws Exception {
updatable.addToObservable(stringReservoir);
| assertThat(updatable, wasNotUpdated()); |
google/agera | agera/src/test/java/com/google/android/agera/ReservoirsTest.java | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
| import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; | public void shouldGiveAbsentValueFromEmptyReservoir() throws Exception {
assertThat(integerReservoir, givesAbsentValueOf(Integer.class));
}
@Test
public void shouldQueueValues() throws Exception {
stringReservoir.accept(STRING_A);
stringReservoir.accept(STRING_A);
stringReservoir.accept(STRING_B);
stringReservoir.accept(STRING_B);
assertThat(stringReservoir, givesPresentValue(STRING_A));
assertThat(stringReservoir, givesPresentValue(STRING_A));
assertThat(stringReservoir, givesPresentValue(STRING_B));
assertThat(stringReservoir, givesPresentValue(STRING_B));
assertThat(stringReservoir, givesAbsentValueOf(String.class));
}
@Test
public void shouldNotGetUpdateFromEmptyReservoir() throws Exception {
updatable.addToObservable(stringReservoir);
assertThat(updatable, wasNotUpdated());
}
@Test
public void shouldGetUpdateOnFirstValue() throws Exception {
updatable.addToObservable(integerReservoir);
give(integerReservoir, INTEGER_1);
| // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
// Path: agera/src/test/java/com/google/android/agera/ReservoirsTest.java
import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
public void shouldGiveAbsentValueFromEmptyReservoir() throws Exception {
assertThat(integerReservoir, givesAbsentValueOf(Integer.class));
}
@Test
public void shouldQueueValues() throws Exception {
stringReservoir.accept(STRING_A);
stringReservoir.accept(STRING_A);
stringReservoir.accept(STRING_B);
stringReservoir.accept(STRING_B);
assertThat(stringReservoir, givesPresentValue(STRING_A));
assertThat(stringReservoir, givesPresentValue(STRING_A));
assertThat(stringReservoir, givesPresentValue(STRING_B));
assertThat(stringReservoir, givesPresentValue(STRING_B));
assertThat(stringReservoir, givesAbsentValueOf(String.class));
}
@Test
public void shouldNotGetUpdateFromEmptyReservoir() throws Exception {
updatable.addToObservable(stringReservoir);
assertThat(updatable, wasNotUpdated());
}
@Test
public void shouldGetUpdateOnFirstValue() throws Exception {
updatable.addToObservable(integerReservoir);
give(integerReservoir, INTEGER_1);
| assertThat(updatable, wasUpdated()); |
google/agera | agera/src/test/java/com/google/android/agera/ReservoirsTest.java | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
| import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; | }
@Test
public void shouldUseCustomQueue() throws Exception {
mockQueue.reject(INTEGER_1).prioritize(STRING_A);
give(customQueueReservoir, INTEGER_2);
give(customQueueReservoir, STRING_B);
give(customQueueReservoir, INTEGER_1);
give(customQueueReservoir, STRING_A);
assertThat(customQueueReservoir, givesPresentValue((Object) STRING_A));
assertThat(customQueueReservoir, givesPresentValue((Object) INTEGER_2));
assertThat(customQueueReservoir, givesPresentValue((Object) STRING_B));
assertThat(customQueueReservoir, givesAbsentValueOf(Object.class));
}
@Test
public void shouldNotGetUpdateWhenCustomQueuePrioritizesAnotherValue() throws Exception {
mockQueue.prioritize(INTEGER_2);
updatable.addToObservable(customQueueReservoir);
give(customQueueReservoir, INTEGER_1);
updatable.resetUpdated();
give(customQueueReservoir, INTEGER_2);
assertThat(updatable, wasNotUpdated());
}
@Test
public void shouldHavePrivateConstructor() { | // Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoir() {
// return reservoir(new ArrayDeque<T>());
// }
//
// Path: agera/src/main/java/com/google/android/agera/Reservoirs.java
// @NonNull
// public static <T> Reservoir<T> reservoirOf(
// @SuppressWarnings("unused") @Nullable final Class<T> clazz) {
// return reservoir();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
// return INSTANCE;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
// return WAS_NOT_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
// return WAS_UPDATED;
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
// private final List<Observable> observables;
//
// private boolean updated;
//
// private MockUpdatable() {
// this.observables = new ArrayList<>();
// this.updated = false;
// }
//
// @NonNull
// public static MockUpdatable mockUpdatable() {
// return new MockUpdatable();
// }
//
// @Override
// public void update() {
// updated = true;
// }
//
// public boolean wasUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// return updated;
// }
//
// public void resetUpdated() {
// runUiThreadTasksIncludingDelayedTasks();
// updated = false;
// }
//
// public void addToObservable(@NonNull final Observable observable) {
// observable.addUpdatable(this);
// observables.add(observable);
// runUiThreadTasksIncludingDelayedTasks();
// }
//
// public void removeFromObservables() {
// for (final Observable observable : observables) {
// observable.removeUpdatable(this);
// }
// observables.clear();
// }
// }
// Path: agera/src/test/java/com/google/android/agera/ReservoirsTest.java
import static com.google.android.agera.Reservoirs.reservoir;
import static com.google.android.agera.Reservoirs.reservoirOf;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static com.google.android.agera.test.matchers.ReservoirGives.givesAbsentValueOf;
import static com.google.android.agera.test.matchers.ReservoirGives.givesPresentValue;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.robolectric.Robolectric.flushForegroundThreadScheduler;
import static org.robolectric.annotation.Config.NONE;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
}
@Test
public void shouldUseCustomQueue() throws Exception {
mockQueue.reject(INTEGER_1).prioritize(STRING_A);
give(customQueueReservoir, INTEGER_2);
give(customQueueReservoir, STRING_B);
give(customQueueReservoir, INTEGER_1);
give(customQueueReservoir, STRING_A);
assertThat(customQueueReservoir, givesPresentValue((Object) STRING_A));
assertThat(customQueueReservoir, givesPresentValue((Object) INTEGER_2));
assertThat(customQueueReservoir, givesPresentValue((Object) STRING_B));
assertThat(customQueueReservoir, givesAbsentValueOf(Object.class));
}
@Test
public void shouldNotGetUpdateWhenCustomQueuePrioritizesAnotherValue() throws Exception {
mockQueue.prioritize(INTEGER_2);
updatable.addToObservable(customQueueReservoir);
give(customQueueReservoir, INTEGER_1);
updatable.resetUpdated();
give(customQueueReservoir, INTEGER_2);
assertThat(updatable, wasNotUpdated());
}
@Test
public void shouldHavePrivateConstructor() { | assertThat(Reservoirs.class, hasPrivateConstructor()); |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/handlers/ColorCommandHandler.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandHandler.java
// public abstract class CommandHandler {
// private final String name, description;
// private final String[] aliases;
//
// /**
// * Construct a new command. Must be registered with {@link CommandRegistry#register(CommandHandler)}
// *
// * @param name Name of the command. When the user types .name in the chat this command will be invoked
// * @param description Short description of what the command does.
// * @param aliases Aliases this command should also react to
// */
// public CommandHandler(String name, String description, String... aliases) {
// this.name = name;
// this.description = description;
// this.aliases = aliases;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String[] getAliases() {
// return aliases;
// }
//
// /**
// * Lice cycle method that gets called before the command is registered and ready to be invoked
// */
// public void onRegister() {
// }
//
// /**
// * Life cycle method that gets called after unregistering a command handler. Can be used to
// * clean up resources.
// */
// public void onUnregister() {
// }
//
// /**
// * Invoke this command and print the result to the user
// *
// * @param cmd Alias or name that was used by the user
// * @param args Arguments to this command, split on whitespaces. Does no do any complex parsing, like quotes.
// * @param printer Printer to write the output of this command to
// * @throws UsageException When the user gave invalid arguments. The message of the throwable will be printed to the user
// */
// public abstract void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException;
//
// /**
// * Show the usage of this command
// *
// * @param cmd Name or alias to show usage help for. If appropriate, the command can display a help for all aliases anyways.
// * @param printer Printer to write the help text to
// */
// public abstract void printUsage(String cmd, CommandOutputPrinter printer);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandOutputPrinter.java
// public interface CommandOutputPrinter {
// /**
// * Print an output message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter println(String msg, Object... formatArgs);
//
// /**
// * Print an error message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter printErrln(String msg, Object... formatArgs);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/UsageException.java
// public class UsageException extends Exception {
// /**
// * @param message Message that will be shown to the user
// */
// public UsageException(String message) {
// super(message);
// }
// }
| import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandHandler;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandOutputPrinter;
import net.frozenbit.plugin5zig.cubecraft.commands.UsageException;
import java.util.Iterator;
import java.util.List; | package net.frozenbit.plugin5zig.cubecraft.commands.handlers;
/**
* Handler for .color
* Shows help for minecrafts color codes
*/
public class ColorCommandHandler extends CommandHandler {
public static final Iterable<ChatColor> RAINBOW_IT =
Iterables.cycle(ChatColor.DARK_RED, ChatColor.RED, ChatColor.GOLD, ChatColor.YELLOW,
ChatColor.GREEN, ChatColor.DARK_GREEN, ChatColor.DARK_AQUA, ChatColor.AQUA,
ChatColor.BLUE, ChatColor.LIGHT_PURPLE, ChatColor.DARK_PURPLE);
public ColorCommandHandler() {
super("color", "Show all color codes", "c");
}
@Override | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandHandler.java
// public abstract class CommandHandler {
// private final String name, description;
// private final String[] aliases;
//
// /**
// * Construct a new command. Must be registered with {@link CommandRegistry#register(CommandHandler)}
// *
// * @param name Name of the command. When the user types .name in the chat this command will be invoked
// * @param description Short description of what the command does.
// * @param aliases Aliases this command should also react to
// */
// public CommandHandler(String name, String description, String... aliases) {
// this.name = name;
// this.description = description;
// this.aliases = aliases;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String[] getAliases() {
// return aliases;
// }
//
// /**
// * Lice cycle method that gets called before the command is registered and ready to be invoked
// */
// public void onRegister() {
// }
//
// /**
// * Life cycle method that gets called after unregistering a command handler. Can be used to
// * clean up resources.
// */
// public void onUnregister() {
// }
//
// /**
// * Invoke this command and print the result to the user
// *
// * @param cmd Alias or name that was used by the user
// * @param args Arguments to this command, split on whitespaces. Does no do any complex parsing, like quotes.
// * @param printer Printer to write the output of this command to
// * @throws UsageException When the user gave invalid arguments. The message of the throwable will be printed to the user
// */
// public abstract void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException;
//
// /**
// * Show the usage of this command
// *
// * @param cmd Name or alias to show usage help for. If appropriate, the command can display a help for all aliases anyways.
// * @param printer Printer to write the help text to
// */
// public abstract void printUsage(String cmd, CommandOutputPrinter printer);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandOutputPrinter.java
// public interface CommandOutputPrinter {
// /**
// * Print an output message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter println(String msg, Object... formatArgs);
//
// /**
// * Print an error message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter printErrln(String msg, Object... formatArgs);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/UsageException.java
// public class UsageException extends Exception {
// /**
// * @param message Message that will be shown to the user
// */
// public UsageException(String message) {
// super(message);
// }
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/handlers/ColorCommandHandler.java
import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandHandler;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandOutputPrinter;
import net.frozenbit.plugin5zig.cubecraft.commands.UsageException;
import java.util.Iterator;
import java.util.List;
package net.frozenbit.plugin5zig.cubecraft.commands.handlers;
/**
* Handler for .color
* Shows help for minecrafts color codes
*/
public class ColorCommandHandler extends CommandHandler {
public static final Iterable<ChatColor> RAINBOW_IT =
Iterables.cycle(ChatColor.DARK_RED, ChatColor.RED, ChatColor.GOLD, ChatColor.YELLOW,
ChatColor.GREEN, ChatColor.DARK_GREEN, ChatColor.DARK_AQUA, ChatColor.AQUA,
ChatColor.BLUE, ChatColor.LIGHT_PURPLE, ChatColor.DARK_PURPLE);
public ColorCommandHandler() {
super("color", "Show all color codes", "c");
}
@Override | public void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException { |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/handlers/ColorCommandHandler.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandHandler.java
// public abstract class CommandHandler {
// private final String name, description;
// private final String[] aliases;
//
// /**
// * Construct a new command. Must be registered with {@link CommandRegistry#register(CommandHandler)}
// *
// * @param name Name of the command. When the user types .name in the chat this command will be invoked
// * @param description Short description of what the command does.
// * @param aliases Aliases this command should also react to
// */
// public CommandHandler(String name, String description, String... aliases) {
// this.name = name;
// this.description = description;
// this.aliases = aliases;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String[] getAliases() {
// return aliases;
// }
//
// /**
// * Lice cycle method that gets called before the command is registered and ready to be invoked
// */
// public void onRegister() {
// }
//
// /**
// * Life cycle method that gets called after unregistering a command handler. Can be used to
// * clean up resources.
// */
// public void onUnregister() {
// }
//
// /**
// * Invoke this command and print the result to the user
// *
// * @param cmd Alias or name that was used by the user
// * @param args Arguments to this command, split on whitespaces. Does no do any complex parsing, like quotes.
// * @param printer Printer to write the output of this command to
// * @throws UsageException When the user gave invalid arguments. The message of the throwable will be printed to the user
// */
// public abstract void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException;
//
// /**
// * Show the usage of this command
// *
// * @param cmd Name or alias to show usage help for. If appropriate, the command can display a help for all aliases anyways.
// * @param printer Printer to write the help text to
// */
// public abstract void printUsage(String cmd, CommandOutputPrinter printer);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandOutputPrinter.java
// public interface CommandOutputPrinter {
// /**
// * Print an output message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter println(String msg, Object... formatArgs);
//
// /**
// * Print an error message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter printErrln(String msg, Object... formatArgs);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/UsageException.java
// public class UsageException extends Exception {
// /**
// * @param message Message that will be shown to the user
// */
// public UsageException(String message) {
// super(message);
// }
// }
| import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandHandler;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandOutputPrinter;
import net.frozenbit.plugin5zig.cubecraft.commands.UsageException;
import java.util.Iterator;
import java.util.List; | package net.frozenbit.plugin5zig.cubecraft.commands.handlers;
/**
* Handler for .color
* Shows help for minecrafts color codes
*/
public class ColorCommandHandler extends CommandHandler {
public static final Iterable<ChatColor> RAINBOW_IT =
Iterables.cycle(ChatColor.DARK_RED, ChatColor.RED, ChatColor.GOLD, ChatColor.YELLOW,
ChatColor.GREEN, ChatColor.DARK_GREEN, ChatColor.DARK_AQUA, ChatColor.AQUA,
ChatColor.BLUE, ChatColor.LIGHT_PURPLE, ChatColor.DARK_PURPLE);
public ColorCommandHandler() {
super("color", "Show all color codes", "c");
}
@Override | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandHandler.java
// public abstract class CommandHandler {
// private final String name, description;
// private final String[] aliases;
//
// /**
// * Construct a new command. Must be registered with {@link CommandRegistry#register(CommandHandler)}
// *
// * @param name Name of the command. When the user types .name in the chat this command will be invoked
// * @param description Short description of what the command does.
// * @param aliases Aliases this command should also react to
// */
// public CommandHandler(String name, String description, String... aliases) {
// this.name = name;
// this.description = description;
// this.aliases = aliases;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String[] getAliases() {
// return aliases;
// }
//
// /**
// * Lice cycle method that gets called before the command is registered and ready to be invoked
// */
// public void onRegister() {
// }
//
// /**
// * Life cycle method that gets called after unregistering a command handler. Can be used to
// * clean up resources.
// */
// public void onUnregister() {
// }
//
// /**
// * Invoke this command and print the result to the user
// *
// * @param cmd Alias or name that was used by the user
// * @param args Arguments to this command, split on whitespaces. Does no do any complex parsing, like quotes.
// * @param printer Printer to write the output of this command to
// * @throws UsageException When the user gave invalid arguments. The message of the throwable will be printed to the user
// */
// public abstract void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException;
//
// /**
// * Show the usage of this command
// *
// * @param cmd Name or alias to show usage help for. If appropriate, the command can display a help for all aliases anyways.
// * @param printer Printer to write the help text to
// */
// public abstract void printUsage(String cmd, CommandOutputPrinter printer);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandOutputPrinter.java
// public interface CommandOutputPrinter {
// /**
// * Print an output message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter println(String msg, Object... formatArgs);
//
// /**
// * Print an error message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter printErrln(String msg, Object... formatArgs);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/UsageException.java
// public class UsageException extends Exception {
// /**
// * @param message Message that will be shown to the user
// */
// public UsageException(String message) {
// super(message);
// }
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/handlers/ColorCommandHandler.java
import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandHandler;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandOutputPrinter;
import net.frozenbit.plugin5zig.cubecraft.commands.UsageException;
import java.util.Iterator;
import java.util.List;
package net.frozenbit.plugin5zig.cubecraft.commands.handlers;
/**
* Handler for .color
* Shows help for minecrafts color codes
*/
public class ColorCommandHandler extends CommandHandler {
public static final Iterable<ChatColor> RAINBOW_IT =
Iterables.cycle(ChatColor.DARK_RED, ChatColor.RED, ChatColor.GOLD, ChatColor.YELLOW,
ChatColor.GREEN, ChatColor.DARK_GREEN, ChatColor.DARK_AQUA, ChatColor.AQUA,
ChatColor.BLUE, ChatColor.LIGHT_PURPLE, ChatColor.DARK_PURPLE);
public ColorCommandHandler() {
super("color", "Show all color codes", "c");
}
@Override | public void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException { |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/items/OpponentItem.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/DuelsGameMode.java
// public class DuelsGameMode extends CubeCraftGameMode {
// private static Stalker stalker;
//
// private NetworkPlayerInfo opponentInfo;
//
// @Override
// public String getName() {
// return "Duels";
// }
//
// public NetworkPlayerInfo getOpponentInfo() {
// return opponentInfo;
// }
//
// public void setOpponentInfo(NetworkPlayerInfo opponentInfo) {
// this.opponentInfo = opponentInfo;
// }
//
// @Override
// public Stalker getStalker() {
// if (stalker == null)
// stalker = new Stalker(this);
// return stalker;
// }
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/StalkedPlayer.java
// public class StalkedPlayer {
// private int kills, deaths;
// private CubeCraftPlayer cubeCraftPlayer;
//
// public StalkedPlayer(CubeCraftPlayer cubeCraftPlayer, int kills, int deaths) {
// this.cubeCraftPlayer = cubeCraftPlayer;
// this.kills = kills;
// this.deaths = deaths;
// }
//
// public StalkedPlayer(CubeCraftPlayer cubeCraftPlayer, JSONObject playerData) {
// this.cubeCraftPlayer = cubeCraftPlayer;
// kills = playerData.getInt("kills");
// deaths = playerData.getInt("deaths");
// }
//
// public String getName() {
// return cubeCraftPlayer.getName();
// }
//
// public UUID getId() {
// return cubeCraftPlayer.getId();
// }
//
// public int getKills() {
// return kills;
// }
//
// public void onKill() {
// ++kills;
// }
//
// public int getDeaths() {
// return deaths;
// }
//
// public void onDeath() {
// ++deaths;
// }
//
// public int getThreat() {
// return deaths - kills;
// }
//
// public ChatColor getThreatColor() {
// if (getThreat() <= 0)
// return ChatColor.WHITE;
// else if (getThreat() <= 3)
// return ChatColor.YELLOW;
// else
// return ChatColor.RED;
// }
//
// public JSONObject toJSON() {
// JSONObject playerData = new JSONObject();
// playerData.put("kills", kills);
// playerData.put("deaths", deaths);
// return playerData;
// }
// }
| import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.mod.modules.GameModeItem;
import eu.the5zig.mod.render.RenderLocation;
import eu.the5zig.mod.util.NetworkPlayerInfo;
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.DuelsGameMode;
import net.frozenbit.plugin5zig.cubecraft.stalker.StalkedPlayer;
import static java.lang.String.format; |
private static String getColoredPing(int ping) {
return ping > 0 ? format("%s%d%s", (ping > 300 ? ChatColor.RED : ping > 150 ? ChatColor.YELLOW : ChatColor.WHITE),
ping, ChatColor.RESET) : "?";
}
@Override
public boolean shouldRender(boolean dummy) {
return super.shouldRender(dummy);
}
@Override
public void render(int x, int y, RenderLocation renderLocation, boolean dummy) {
if (dummy) {
if (System.currentTimeMillis() - lastDummyPingTime > 1000) {
lastDummyPingTime = System.currentTimeMillis();
dummyPing = (int) (Math.random() * 500.0);
}
The5zigAPI.getAPI().getRenderHelper().drawString(formatOpponentInfo("nullEuro", dummyPing), x, y);
The5zigAPI.getAPI().getRenderHelper().drawString(formatOpponentStats(3, 7), x, y + 10);
lines = 2;
return;
}
NetworkPlayerInfo opponentInfo = getGameMode().getOpponentInfo();
if (opponentInfo == null) {
The5zigAPI.getAPI().getRenderHelper().drawString(getPrefix() + ChatColor.GRAY + "...", x, y);
lines = 1;
return;
}
The5zigAPI.getAPI().getRenderHelper().drawString(formatOpponentInfo(opponentInfo.getGameProfile().getName(), opponentInfo.getPing()), x, y); | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/DuelsGameMode.java
// public class DuelsGameMode extends CubeCraftGameMode {
// private static Stalker stalker;
//
// private NetworkPlayerInfo opponentInfo;
//
// @Override
// public String getName() {
// return "Duels";
// }
//
// public NetworkPlayerInfo getOpponentInfo() {
// return opponentInfo;
// }
//
// public void setOpponentInfo(NetworkPlayerInfo opponentInfo) {
// this.opponentInfo = opponentInfo;
// }
//
// @Override
// public Stalker getStalker() {
// if (stalker == null)
// stalker = new Stalker(this);
// return stalker;
// }
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/StalkedPlayer.java
// public class StalkedPlayer {
// private int kills, deaths;
// private CubeCraftPlayer cubeCraftPlayer;
//
// public StalkedPlayer(CubeCraftPlayer cubeCraftPlayer, int kills, int deaths) {
// this.cubeCraftPlayer = cubeCraftPlayer;
// this.kills = kills;
// this.deaths = deaths;
// }
//
// public StalkedPlayer(CubeCraftPlayer cubeCraftPlayer, JSONObject playerData) {
// this.cubeCraftPlayer = cubeCraftPlayer;
// kills = playerData.getInt("kills");
// deaths = playerData.getInt("deaths");
// }
//
// public String getName() {
// return cubeCraftPlayer.getName();
// }
//
// public UUID getId() {
// return cubeCraftPlayer.getId();
// }
//
// public int getKills() {
// return kills;
// }
//
// public void onKill() {
// ++kills;
// }
//
// public int getDeaths() {
// return deaths;
// }
//
// public void onDeath() {
// ++deaths;
// }
//
// public int getThreat() {
// return deaths - kills;
// }
//
// public ChatColor getThreatColor() {
// if (getThreat() <= 0)
// return ChatColor.WHITE;
// else if (getThreat() <= 3)
// return ChatColor.YELLOW;
// else
// return ChatColor.RED;
// }
//
// public JSONObject toJSON() {
// JSONObject playerData = new JSONObject();
// playerData.put("kills", kills);
// playerData.put("deaths", deaths);
// return playerData;
// }
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/items/OpponentItem.java
import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.mod.modules.GameModeItem;
import eu.the5zig.mod.render.RenderLocation;
import eu.the5zig.mod.util.NetworkPlayerInfo;
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.DuelsGameMode;
import net.frozenbit.plugin5zig.cubecraft.stalker.StalkedPlayer;
import static java.lang.String.format;
private static String getColoredPing(int ping) {
return ping > 0 ? format("%s%d%s", (ping > 300 ? ChatColor.RED : ping > 150 ? ChatColor.YELLOW : ChatColor.WHITE),
ping, ChatColor.RESET) : "?";
}
@Override
public boolean shouldRender(boolean dummy) {
return super.shouldRender(dummy);
}
@Override
public void render(int x, int y, RenderLocation renderLocation, boolean dummy) {
if (dummy) {
if (System.currentTimeMillis() - lastDummyPingTime > 1000) {
lastDummyPingTime = System.currentTimeMillis();
dummyPing = (int) (Math.random() * 500.0);
}
The5zigAPI.getAPI().getRenderHelper().drawString(formatOpponentInfo("nullEuro", dummyPing), x, y);
The5zigAPI.getAPI().getRenderHelper().drawString(formatOpponentStats(3, 7), x, y + 10);
lines = 2;
return;
}
NetworkPlayerInfo opponentInfo = getGameMode().getOpponentInfo();
if (opponentInfo == null) {
The5zigAPI.getAPI().getRenderHelper().drawString(getPrefix() + ChatColor.GRAY + "...", x, y);
lines = 1;
return;
}
The5zigAPI.getAPI().getRenderHelper().drawString(formatOpponentInfo(opponentInfo.getGameProfile().getName(), opponentInfo.getPing()), x, y); | StalkedPlayer stalkedOpponent = getGameMode().getStalker().getStalkedPlayerById(opponentInfo.getGameProfile().getId()); |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/TimeLootVotableMode.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/CubeCraftPlayer.java
// public class CubeCraftPlayer {
//
// private final Rank rank;
// private List<String> tags;
// private NetworkPlayerInfo info;
//
// public CubeCraftPlayer(Rank rank, List<String> tags, NetworkPlayerInfo info) {
// if (rank == null || tags == null || info == null)
// throw new IllegalArgumentException("rank, tags and info must not be null");
// this.rank = rank;
// this.tags = tags;
// this.info = info;
// }
//
// public boolean isStaff() {
// return tags.contains("Mod")
// || tags.contains("SrMod")
// || tags.contains("Dev")
// || tags.contains("Admin")
// || tags.contains("Vanished");
// }
//
// public Rank getRank() {
// return rank;
// }
//
// public String getName() {
// return info.getGameProfile().getName();
// }
//
// public UUID getId() {
// return info.getGameProfile().getId();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CubeCraftPlayer that = (CubeCraftPlayer) o;
//
// return getName().equals(that.getName());
//
// }
//
// @Override
// public String toString() {
// return "CubeCraftPlayer{" +
// "rank=" + rank +
// ", tags=" + Arrays.toString(tags.toArray()) +
// ", name='" + getName() + '\'' +
// '}';
// }
//
// @Override
// public int hashCode() {
// return getName().hashCode();
// }
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/Rank.java
// public enum Rank {
// NONE, STONE, IRON, LAPIZ, GOLD, DIAMOND, EMERALD, OBSIDIAN
// }
| import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.CubeCraftPlayer;
import net.frozenbit.plugin5zig.cubecraft.Rank;
import java.util.Map;
import static com.google.common.base.MoreObjects.firstNonNull; | package net.frozenbit.plugin5zig.cubecraft.gamemodes;
/**
* Common superclass of gamemodes that support voting for time and loot
*/
public abstract class TimeLootVotableMode extends VotableCubeCraftGameMode {
@Override | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/CubeCraftPlayer.java
// public class CubeCraftPlayer {
//
// private final Rank rank;
// private List<String> tags;
// private NetworkPlayerInfo info;
//
// public CubeCraftPlayer(Rank rank, List<String> tags, NetworkPlayerInfo info) {
// if (rank == null || tags == null || info == null)
// throw new IllegalArgumentException("rank, tags and info must not be null");
// this.rank = rank;
// this.tags = tags;
// this.info = info;
// }
//
// public boolean isStaff() {
// return tags.contains("Mod")
// || tags.contains("SrMod")
// || tags.contains("Dev")
// || tags.contains("Admin")
// || tags.contains("Vanished");
// }
//
// public Rank getRank() {
// return rank;
// }
//
// public String getName() {
// return info.getGameProfile().getName();
// }
//
// public UUID getId() {
// return info.getGameProfile().getId();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CubeCraftPlayer that = (CubeCraftPlayer) o;
//
// return getName().equals(that.getName());
//
// }
//
// @Override
// public String toString() {
// return "CubeCraftPlayer{" +
// "rank=" + rank +
// ", tags=" + Arrays.toString(tags.toArray()) +
// ", name='" + getName() + '\'' +
// '}';
// }
//
// @Override
// public int hashCode() {
// return getName().hashCode();
// }
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/Rank.java
// public enum Rank {
// NONE, STONE, IRON, LAPIZ, GOLD, DIAMOND, EMERALD, OBSIDIAN
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/TimeLootVotableMode.java
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.CubeCraftPlayer;
import net.frozenbit.plugin5zig.cubecraft.Rank;
import java.util.Map;
import static com.google.common.base.MoreObjects.firstNonNull;
package net.frozenbit.plugin5zig.cubecraft.gamemodes;
/**
* Common superclass of gamemodes that support voting for time and loot
*/
public abstract class TimeLootVotableMode extends VotableCubeCraftGameMode {
@Override | protected String formatVoteString(CubeCraftPlayer player, Map<String, String> vote) { |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/TimeLootVotableMode.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/CubeCraftPlayer.java
// public class CubeCraftPlayer {
//
// private final Rank rank;
// private List<String> tags;
// private NetworkPlayerInfo info;
//
// public CubeCraftPlayer(Rank rank, List<String> tags, NetworkPlayerInfo info) {
// if (rank == null || tags == null || info == null)
// throw new IllegalArgumentException("rank, tags and info must not be null");
// this.rank = rank;
// this.tags = tags;
// this.info = info;
// }
//
// public boolean isStaff() {
// return tags.contains("Mod")
// || tags.contains("SrMod")
// || tags.contains("Dev")
// || tags.contains("Admin")
// || tags.contains("Vanished");
// }
//
// public Rank getRank() {
// return rank;
// }
//
// public String getName() {
// return info.getGameProfile().getName();
// }
//
// public UUID getId() {
// return info.getGameProfile().getId();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CubeCraftPlayer that = (CubeCraftPlayer) o;
//
// return getName().equals(that.getName());
//
// }
//
// @Override
// public String toString() {
// return "CubeCraftPlayer{" +
// "rank=" + rank +
// ", tags=" + Arrays.toString(tags.toArray()) +
// ", name='" + getName() + '\'' +
// '}';
// }
//
// @Override
// public int hashCode() {
// return getName().hashCode();
// }
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/Rank.java
// public enum Rank {
// NONE, STONE, IRON, LAPIZ, GOLD, DIAMOND, EMERALD, OBSIDIAN
// }
| import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.CubeCraftPlayer;
import net.frozenbit.plugin5zig.cubecraft.Rank;
import java.util.Map;
import static com.google.common.base.MoreObjects.firstNonNull; | package net.frozenbit.plugin5zig.cubecraft.gamemodes;
/**
* Common superclass of gamemodes that support voting for time and loot
*/
public abstract class TimeLootVotableMode extends VotableCubeCraftGameMode {
@Override
protected String formatVoteString(CubeCraftPlayer player, Map<String, String> vote) {
DaytimeType time = vote.containsKey("time") ?
DaytimeType.fromString(vote.get("time")) : DaytimeType.NONE; | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/CubeCraftPlayer.java
// public class CubeCraftPlayer {
//
// private final Rank rank;
// private List<String> tags;
// private NetworkPlayerInfo info;
//
// public CubeCraftPlayer(Rank rank, List<String> tags, NetworkPlayerInfo info) {
// if (rank == null || tags == null || info == null)
// throw new IllegalArgumentException("rank, tags and info must not be null");
// this.rank = rank;
// this.tags = tags;
// this.info = info;
// }
//
// public boolean isStaff() {
// return tags.contains("Mod")
// || tags.contains("SrMod")
// || tags.contains("Dev")
// || tags.contains("Admin")
// || tags.contains("Vanished");
// }
//
// public Rank getRank() {
// return rank;
// }
//
// public String getName() {
// return info.getGameProfile().getName();
// }
//
// public UUID getId() {
// return info.getGameProfile().getId();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CubeCraftPlayer that = (CubeCraftPlayer) o;
//
// return getName().equals(that.getName());
//
// }
//
// @Override
// public String toString() {
// return "CubeCraftPlayer{" +
// "rank=" + rank +
// ", tags=" + Arrays.toString(tags.toArray()) +
// ", name='" + getName() + '\'' +
// '}';
// }
//
// @Override
// public int hashCode() {
// return getName().hashCode();
// }
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/Rank.java
// public enum Rank {
// NONE, STONE, IRON, LAPIZ, GOLD, DIAMOND, EMERALD, OBSIDIAN
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/TimeLootVotableMode.java
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.CubeCraftPlayer;
import net.frozenbit.plugin5zig.cubecraft.Rank;
import java.util.Map;
import static com.google.common.base.MoreObjects.firstNonNull;
package net.frozenbit.plugin5zig.cubecraft.gamemodes;
/**
* Common superclass of gamemodes that support voting for time and loot
*/
public abstract class TimeLootVotableMode extends VotableCubeCraftGameMode {
@Override
protected String formatVoteString(CubeCraftPlayer player, Map<String, String> vote) {
DaytimeType time = vote.containsKey("time") ?
DaytimeType.fromString(vote.get("time")) : DaytimeType.NONE; | return (player.getRank() == Rank.GOLD ? ChatColor.DARK_GRAY : |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/StalkedPlayer.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/CubeCraftPlayer.java
// public class CubeCraftPlayer {
//
// private final Rank rank;
// private List<String> tags;
// private NetworkPlayerInfo info;
//
// public CubeCraftPlayer(Rank rank, List<String> tags, NetworkPlayerInfo info) {
// if (rank == null || tags == null || info == null)
// throw new IllegalArgumentException("rank, tags and info must not be null");
// this.rank = rank;
// this.tags = tags;
// this.info = info;
// }
//
// public boolean isStaff() {
// return tags.contains("Mod")
// || tags.contains("SrMod")
// || tags.contains("Dev")
// || tags.contains("Admin")
// || tags.contains("Vanished");
// }
//
// public Rank getRank() {
// return rank;
// }
//
// public String getName() {
// return info.getGameProfile().getName();
// }
//
// public UUID getId() {
// return info.getGameProfile().getId();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CubeCraftPlayer that = (CubeCraftPlayer) o;
//
// return getName().equals(that.getName());
//
// }
//
// @Override
// public String toString() {
// return "CubeCraftPlayer{" +
// "rank=" + rank +
// ", tags=" + Arrays.toString(tags.toArray()) +
// ", name='" + getName() + '\'' +
// '}';
// }
//
// @Override
// public int hashCode() {
// return getName().hashCode();
// }
// }
| import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.CubeCraftPlayer;
import org.json.JSONObject;
import java.util.UUID; | package net.frozenbit.plugin5zig.cubecraft.stalker;
public class StalkedPlayer {
private int kills, deaths; | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/CubeCraftPlayer.java
// public class CubeCraftPlayer {
//
// private final Rank rank;
// private List<String> tags;
// private NetworkPlayerInfo info;
//
// public CubeCraftPlayer(Rank rank, List<String> tags, NetworkPlayerInfo info) {
// if (rank == null || tags == null || info == null)
// throw new IllegalArgumentException("rank, tags and info must not be null");
// this.rank = rank;
// this.tags = tags;
// this.info = info;
// }
//
// public boolean isStaff() {
// return tags.contains("Mod")
// || tags.contains("SrMod")
// || tags.contains("Dev")
// || tags.contains("Admin")
// || tags.contains("Vanished");
// }
//
// public Rank getRank() {
// return rank;
// }
//
// public String getName() {
// return info.getGameProfile().getName();
// }
//
// public UUID getId() {
// return info.getGameProfile().getId();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CubeCraftPlayer that = (CubeCraftPlayer) o;
//
// return getName().equals(that.getName());
//
// }
//
// @Override
// public String toString() {
// return "CubeCraftPlayer{" +
// "rank=" + rank +
// ", tags=" + Arrays.toString(tags.toArray()) +
// ", name='" + getName() + '\'' +
// '}';
// }
//
// @Override
// public int hashCode() {
// return getName().hashCode();
// }
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/StalkedPlayer.java
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.CubeCraftPlayer;
import org.json.JSONObject;
import java.util.UUID;
package net.frozenbit.plugin5zig.cubecraft.stalker;
public class StalkedPlayer {
private int kills, deaths; | private CubeCraftPlayer cubeCraftPlayer; |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/TowerDefenceGameMode.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/Stalker.java
// public class Stalker {
//
// private Storage storage;
// private String ownName;
// private GameMode gameMode;
// private final List<StalkedPlayer> stalkedPlayerList;
// private final List<StalkedPlayer> internalStalkedPlayerList;
// private int maxNameWidth = 0;
// private int shownPlayerCount = 0;
// private int playerListIteration = 0;
//
// public Stalker(GameMode gameMode) {
// this.gameMode = gameMode;
// storage = new Storage(gameMode);
// ownName = The5zigAPI.getAPI().getGameProfile().getName();
// stalkedPlayerList = new ArrayList<>();
// internalStalkedPlayerList = new ArrayList<>();
// }
//
// public void onKill(String victim, String killer) {
// boolean kill = killer.equals(ownName);
// boolean death = victim.equals(ownName);
// if (!kill && !death)
// return;
// String otherName = kill ? victim : killer;
// StalkedPlayer otherPlayer = null;
// synchronized (stalkedPlayerList) {
// for (StalkedPlayer player : stalkedPlayerList) {
// if (player.getName().equals(otherName)) {
// otherPlayer = player;
// break;
// }
// }
// }
// if (otherPlayer == null) {
// Main.getInstance().getLogger().println(String.format("Player %s is not in the player list", otherName));
// return;
// }
// if (otherPlayer.getKills() == 0 && otherPlayer.getDeaths() == 0)
// ++shownPlayerCount;
// if (kill)
// otherPlayer.onKill();
// else
// otherPlayer.onDeath();
// final StalkedPlayer storedPlayer = otherPlayer;
// new Thread(() -> storage.storePlayer(storedPlayer)).start();
// }
//
// public void onPlayerListUpdate(final List<CubeCraftPlayer> playerList) {
// maxNameWidth = 0;
// final int frozenPlayerListIteration = ++playerListIteration;
// shownPlayerCount = 0;
// new Thread(() -> {
// synchronized (internalStalkedPlayerList) {
// internalStalkedPlayerList.clear();
// for (CubeCraftPlayer cubeCraftPlayer : playerList) {
// if (playerListIteration != frozenPlayerListIteration)
// return;
// maxNameWidth = Math.max(maxNameWidth, The5zigAPI.getAPI().getRenderHelper().getStringWidth(cubeCraftPlayer.getName()));
// StalkedPlayer stalkedPlayer = storage.getStalkedPlayer(cubeCraftPlayer);
// if (stalkedPlayer.getKills() != 0 || stalkedPlayer.getDeaths() != 0)
// ++shownPlayerCount;
// internalStalkedPlayerList.add(stalkedPlayer);
// }
// if (playerListIteration != frozenPlayerListIteration)
// return;
// synchronized (stalkedPlayerList) {
// stalkedPlayerList.clear();
// stalkedPlayerList.addAll(internalStalkedPlayerList);
// }
// }
// }).start();
// }
//
// public List<StalkedPlayer> getStalkedPlayerList() {
// return stalkedPlayerList;
// }
//
// public StalkedPlayer getStalkedPlayerById(UUID id) {
// synchronized (stalkedPlayerList) {
// for (StalkedPlayer stalkedPlayer : stalkedPlayerList) {
// if (stalkedPlayer.getId().equals(id)) {
// return stalkedPlayer;
// }
// }
// }
// return null;
// }
//
// public int getMaxNameWidth() {
// return maxNameWidth;
// }
//
// public int getShownPlayerCount() {
// return shownPlayerCount;
// }
//
// public void close() {
// storage.close();
// }
//
// }
| import eu.the5zig.mod.gui.ingame.ItemStack;
import net.frozenbit.plugin5zig.cubecraft.stalker.Stalker;
import java.util.Collections;
import java.util.List; | package net.frozenbit.plugin5zig.cubecraft.gamemodes;
public class TowerDefenceGameMode extends CubeCraftGameMode {
private List<Tower> towers = Collections.emptyList();
private int coins;
private int exp;
private int castleHealth;
@Override
public boolean isStalkerEnabled() {
return false;
}
@Override | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/Stalker.java
// public class Stalker {
//
// private Storage storage;
// private String ownName;
// private GameMode gameMode;
// private final List<StalkedPlayer> stalkedPlayerList;
// private final List<StalkedPlayer> internalStalkedPlayerList;
// private int maxNameWidth = 0;
// private int shownPlayerCount = 0;
// private int playerListIteration = 0;
//
// public Stalker(GameMode gameMode) {
// this.gameMode = gameMode;
// storage = new Storage(gameMode);
// ownName = The5zigAPI.getAPI().getGameProfile().getName();
// stalkedPlayerList = new ArrayList<>();
// internalStalkedPlayerList = new ArrayList<>();
// }
//
// public void onKill(String victim, String killer) {
// boolean kill = killer.equals(ownName);
// boolean death = victim.equals(ownName);
// if (!kill && !death)
// return;
// String otherName = kill ? victim : killer;
// StalkedPlayer otherPlayer = null;
// synchronized (stalkedPlayerList) {
// for (StalkedPlayer player : stalkedPlayerList) {
// if (player.getName().equals(otherName)) {
// otherPlayer = player;
// break;
// }
// }
// }
// if (otherPlayer == null) {
// Main.getInstance().getLogger().println(String.format("Player %s is not in the player list", otherName));
// return;
// }
// if (otherPlayer.getKills() == 0 && otherPlayer.getDeaths() == 0)
// ++shownPlayerCount;
// if (kill)
// otherPlayer.onKill();
// else
// otherPlayer.onDeath();
// final StalkedPlayer storedPlayer = otherPlayer;
// new Thread(() -> storage.storePlayer(storedPlayer)).start();
// }
//
// public void onPlayerListUpdate(final List<CubeCraftPlayer> playerList) {
// maxNameWidth = 0;
// final int frozenPlayerListIteration = ++playerListIteration;
// shownPlayerCount = 0;
// new Thread(() -> {
// synchronized (internalStalkedPlayerList) {
// internalStalkedPlayerList.clear();
// for (CubeCraftPlayer cubeCraftPlayer : playerList) {
// if (playerListIteration != frozenPlayerListIteration)
// return;
// maxNameWidth = Math.max(maxNameWidth, The5zigAPI.getAPI().getRenderHelper().getStringWidth(cubeCraftPlayer.getName()));
// StalkedPlayer stalkedPlayer = storage.getStalkedPlayer(cubeCraftPlayer);
// if (stalkedPlayer.getKills() != 0 || stalkedPlayer.getDeaths() != 0)
// ++shownPlayerCount;
// internalStalkedPlayerList.add(stalkedPlayer);
// }
// if (playerListIteration != frozenPlayerListIteration)
// return;
// synchronized (stalkedPlayerList) {
// stalkedPlayerList.clear();
// stalkedPlayerList.addAll(internalStalkedPlayerList);
// }
// }
// }).start();
// }
//
// public List<StalkedPlayer> getStalkedPlayerList() {
// return stalkedPlayerList;
// }
//
// public StalkedPlayer getStalkedPlayerById(UUID id) {
// synchronized (stalkedPlayerList) {
// for (StalkedPlayer stalkedPlayer : stalkedPlayerList) {
// if (stalkedPlayer.getId().equals(id)) {
// return stalkedPlayer;
// }
// }
// }
// return null;
// }
//
// public int getMaxNameWidth() {
// return maxNameWidth;
// }
//
// public int getShownPlayerCount() {
// return shownPlayerCount;
// }
//
// public void close() {
// storage.close();
// }
//
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/TowerDefenceGameMode.java
import eu.the5zig.mod.gui.ingame.ItemStack;
import net.frozenbit.plugin5zig.cubecraft.stalker.Stalker;
import java.util.Collections;
import java.util.List;
package net.frozenbit.plugin5zig.cubecraft.gamemodes;
public class TowerDefenceGameMode extends CubeCraftGameMode {
private List<Tower> towers = Collections.emptyList();
private int coins;
private int exp;
private int castleHealth;
@Override
public boolean isStalkerEnabled() {
return false;
}
@Override | public Stalker getStalker() { |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/items/GameModifiersItem.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/TimeLootVotableMode.java
// public abstract class TimeLootVotableMode extends VotableCubeCraftGameMode {
// @Override
// protected String formatVoteString(CubeCraftPlayer player, Map<String, String> vote) {
// DaytimeType time = vote.containsKey("time") ?
// DaytimeType.fromString(vote.get("time")) : DaytimeType.NONE;
// return (player.getRank() == Rank.GOLD ? ChatColor.DARK_GRAY :
// LootType.fromString(firstNonNull(vote.get("loot"), "")).color)
// + player.getName() + ChatColor.RESET + " " + time.coloredSymbol();
// }
//
// @Override
// public String formatVoteResult(Map<String, String> draw) {
// LootType lootType = LootType.fromString(draw.get("loot"));
// return lootType + "/" + draw.get("time");
// }
//
// @Override
// protected boolean isShownInVoterList(CubeCraftPlayer player) {
// return player.isStaff() || Rank.GOLD.compareTo(player.getRank()) <= 0;
// }
//
// @Override
// protected String[] getVoteCategories() {
// return new String[]{"loot", "time"};
// }
//
// public enum DaytimeType {
// DAY_TIME("Day", ChatColor.GOLD, "●"),
// SUNSET("Sunset", ChatColor.GOLD, "◓"),
// NIGHT_TIME("Night", ChatColor.GOLD, "☾"),
// NONE("", ChatColor.RESET, "");
//
// public final String chatName;
// public final ChatColor color;
// public final String symbol;
//
// DaytimeType(String chatName, ChatColor color, String symbol) {
// this.chatName = chatName;
// this.color = color;
// this.symbol = symbol;
// }
//
// public static DaytimeType fromString(String daytime) {
// for (DaytimeType daytimeType : DaytimeType.values()) {
// if (daytimeType.chatName.equals(daytime)) {
// return daytimeType;
// }
// }
// throw new IllegalArgumentException("value '" + daytime + "' unknown");
// }
//
// public String coloredSymbol() {
// return color + symbol + ChatColor.RESET;
// }
//
// @Override
// public String toString() {
// return chatName;
// }
// }
//
// public enum LootType {
// NONE("", ChatColor.GRAY),
// BASIC("Basic", ChatColor.GREEN),
// NORMAL("Normal", ChatColor.YELLOW),
// OVERPOWERED("Overpowered", ChatColor.DARK_RED);
//
// public final String chatName;
// public final ChatColor color;
//
// LootType(String chatName, ChatColor color) {
// this.chatName = chatName;
// this.color = color;
// }
//
// public static LootType fromString(String string) {
// for (LootType type : LootType.values()) {
// if (type.chatName.equalsIgnoreCase(string)) {
// return type;
// }
// }
// throw new IllegalArgumentException("type '" + string + "' not found");
// }
//
// @Override
// public String toString() {
// return color + chatName + ChatColor.RESET;
// }
//
// }
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/VotableCubeCraftGameMode.java
// public abstract class VotableCubeCraftGameMode extends CubeCraftGameMode {
// private Table<CubeCraftPlayer, String, String> votes = HashBasedTable.create();
// private Map<String, String> draw = new HashMap<>();
// private TimeLootVotableMode.LootType chestType = TimeLootVotableMode.LootType.NONE;
// private long lastDrawResultTime;
// private ArrayList<String> formattedVoterList;
// private String formattedVoteResult;
//
// protected abstract String formatVoteString(CubeCraftPlayer player, Map<String, String> vote);
//
// protected abstract String formatVoteResult(Map<String, String> draw);
//
// protected abstract boolean isShownInVoterList(CubeCraftPlayer player);
//
// protected abstract String[] getVoteCategories();
//
// public final long getVoteResultTime() {
// return lastDrawResultTime;
// }
//
// public final String getVoteResult() {
// if (formattedVoteResult == null) {
// formattedVoteResult = isDrawDone() ? formatVoteResult(Collections.unmodifiableMap(draw)) : "";
// }
// return formattedVoteResult;
// }
//
// public boolean isDrawDone() {
// for (String category : getVoteCategories()) {
// if (!draw.containsKey(category)) {
// return false;
// }
// }
// return true;
// }
//
// public final List<String> getFormattedVoterList() {
// if (formattedVoterList == null) {
// formattedVoterList = new ArrayList<>();
// for (CubeCraftPlayer player : players) {
// if (isShownInVoterList(player)) {
// formattedVoterList.add(formatVoteString(player, votes.row(player)));
// }
// }
// }
// return formattedVoterList;
// }
//
// @Override
// public void playerListUpdate() {
// super.playerListUpdate();
// formattedVoterList = null;
// }
//
// public final void onDrawResult(String category, String vote) {
// draw.put(category, vote);
// lastDrawResultTime = System.currentTimeMillis();
// formattedVoteResult = null;
// }
//
// public final void onVote(String playerName, String category, String vote) {
// CubeCraftPlayer voter = getPlayerByName(playerName);
// votes.put(voter, category, vote);
// formattedVoterList = null;
// }
//
// }
| import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.mod.modules.GameModeItem;
import eu.the5zig.mod.render.RenderLocation;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.TimeLootVotableMode;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.VotableCubeCraftGameMode; | package net.frozenbit.plugin5zig.cubecraft.items;
public class GameModifiersItem extends GameModeItem<VotableCubeCraftGameMode> {
public GameModifiersItem() {
super(VotableCubeCraftGameMode.class);
}
@Override
protected Object getValue(boolean dummy) { | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/TimeLootVotableMode.java
// public abstract class TimeLootVotableMode extends VotableCubeCraftGameMode {
// @Override
// protected String formatVoteString(CubeCraftPlayer player, Map<String, String> vote) {
// DaytimeType time = vote.containsKey("time") ?
// DaytimeType.fromString(vote.get("time")) : DaytimeType.NONE;
// return (player.getRank() == Rank.GOLD ? ChatColor.DARK_GRAY :
// LootType.fromString(firstNonNull(vote.get("loot"), "")).color)
// + player.getName() + ChatColor.RESET + " " + time.coloredSymbol();
// }
//
// @Override
// public String formatVoteResult(Map<String, String> draw) {
// LootType lootType = LootType.fromString(draw.get("loot"));
// return lootType + "/" + draw.get("time");
// }
//
// @Override
// protected boolean isShownInVoterList(CubeCraftPlayer player) {
// return player.isStaff() || Rank.GOLD.compareTo(player.getRank()) <= 0;
// }
//
// @Override
// protected String[] getVoteCategories() {
// return new String[]{"loot", "time"};
// }
//
// public enum DaytimeType {
// DAY_TIME("Day", ChatColor.GOLD, "●"),
// SUNSET("Sunset", ChatColor.GOLD, "◓"),
// NIGHT_TIME("Night", ChatColor.GOLD, "☾"),
// NONE("", ChatColor.RESET, "");
//
// public final String chatName;
// public final ChatColor color;
// public final String symbol;
//
// DaytimeType(String chatName, ChatColor color, String symbol) {
// this.chatName = chatName;
// this.color = color;
// this.symbol = symbol;
// }
//
// public static DaytimeType fromString(String daytime) {
// for (DaytimeType daytimeType : DaytimeType.values()) {
// if (daytimeType.chatName.equals(daytime)) {
// return daytimeType;
// }
// }
// throw new IllegalArgumentException("value '" + daytime + "' unknown");
// }
//
// public String coloredSymbol() {
// return color + symbol + ChatColor.RESET;
// }
//
// @Override
// public String toString() {
// return chatName;
// }
// }
//
// public enum LootType {
// NONE("", ChatColor.GRAY),
// BASIC("Basic", ChatColor.GREEN),
// NORMAL("Normal", ChatColor.YELLOW),
// OVERPOWERED("Overpowered", ChatColor.DARK_RED);
//
// public final String chatName;
// public final ChatColor color;
//
// LootType(String chatName, ChatColor color) {
// this.chatName = chatName;
// this.color = color;
// }
//
// public static LootType fromString(String string) {
// for (LootType type : LootType.values()) {
// if (type.chatName.equalsIgnoreCase(string)) {
// return type;
// }
// }
// throw new IllegalArgumentException("type '" + string + "' not found");
// }
//
// @Override
// public String toString() {
// return color + chatName + ChatColor.RESET;
// }
//
// }
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/VotableCubeCraftGameMode.java
// public abstract class VotableCubeCraftGameMode extends CubeCraftGameMode {
// private Table<CubeCraftPlayer, String, String> votes = HashBasedTable.create();
// private Map<String, String> draw = new HashMap<>();
// private TimeLootVotableMode.LootType chestType = TimeLootVotableMode.LootType.NONE;
// private long lastDrawResultTime;
// private ArrayList<String> formattedVoterList;
// private String formattedVoteResult;
//
// protected abstract String formatVoteString(CubeCraftPlayer player, Map<String, String> vote);
//
// protected abstract String formatVoteResult(Map<String, String> draw);
//
// protected abstract boolean isShownInVoterList(CubeCraftPlayer player);
//
// protected abstract String[] getVoteCategories();
//
// public final long getVoteResultTime() {
// return lastDrawResultTime;
// }
//
// public final String getVoteResult() {
// if (formattedVoteResult == null) {
// formattedVoteResult = isDrawDone() ? formatVoteResult(Collections.unmodifiableMap(draw)) : "";
// }
// return formattedVoteResult;
// }
//
// public boolean isDrawDone() {
// for (String category : getVoteCategories()) {
// if (!draw.containsKey(category)) {
// return false;
// }
// }
// return true;
// }
//
// public final List<String> getFormattedVoterList() {
// if (formattedVoterList == null) {
// formattedVoterList = new ArrayList<>();
// for (CubeCraftPlayer player : players) {
// if (isShownInVoterList(player)) {
// formattedVoterList.add(formatVoteString(player, votes.row(player)));
// }
// }
// }
// return formattedVoterList;
// }
//
// @Override
// public void playerListUpdate() {
// super.playerListUpdate();
// formattedVoterList = null;
// }
//
// public final void onDrawResult(String category, String vote) {
// draw.put(category, vote);
// lastDrawResultTime = System.currentTimeMillis();
// formattedVoteResult = null;
// }
//
// public final void onVote(String playerName, String category, String vote) {
// CubeCraftPlayer voter = getPlayerByName(playerName);
// votes.put(voter, category, vote);
// formattedVoterList = null;
// }
//
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/items/GameModifiersItem.java
import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.mod.modules.GameModeItem;
import eu.the5zig.mod.render.RenderLocation;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.TimeLootVotableMode;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.VotableCubeCraftGameMode;
package net.frozenbit.plugin5zig.cubecraft.items;
public class GameModifiersItem extends GameModeItem<VotableCubeCraftGameMode> {
public GameModifiersItem() {
super(VotableCubeCraftGameMode.class);
}
@Override
protected Object getValue(boolean dummy) { | return dummy ? TimeLootVotableMode.LootType.OVERPOWERED : getGameMode().getVoteResult(); |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/handlers/RespondCommandHandler.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandHandler.java
// public abstract class CommandHandler {
// private final String name, description;
// private final String[] aliases;
//
// /**
// * Construct a new command. Must be registered with {@link CommandRegistry#register(CommandHandler)}
// *
// * @param name Name of the command. When the user types .name in the chat this command will be invoked
// * @param description Short description of what the command does.
// * @param aliases Aliases this command should also react to
// */
// public CommandHandler(String name, String description, String... aliases) {
// this.name = name;
// this.description = description;
// this.aliases = aliases;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String[] getAliases() {
// return aliases;
// }
//
// /**
// * Lice cycle method that gets called before the command is registered and ready to be invoked
// */
// public void onRegister() {
// }
//
// /**
// * Life cycle method that gets called after unregistering a command handler. Can be used to
// * clean up resources.
// */
// public void onUnregister() {
// }
//
// /**
// * Invoke this command and print the result to the user
// *
// * @param cmd Alias or name that was used by the user
// * @param args Arguments to this command, split on whitespaces. Does no do any complex parsing, like quotes.
// * @param printer Printer to write the output of this command to
// * @throws UsageException When the user gave invalid arguments. The message of the throwable will be printed to the user
// */
// public abstract void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException;
//
// /**
// * Show the usage of this command
// *
// * @param cmd Name or alias to show usage help for. If appropriate, the command can display a help for all aliases anyways.
// * @param printer Printer to write the help text to
// */
// public abstract void printUsage(String cmd, CommandOutputPrinter printer);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandOutputPrinter.java
// public interface CommandOutputPrinter {
// /**
// * Print an output message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter println(String msg, Object... formatArgs);
//
// /**
// * Print an error message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter printErrln(String msg, Object... formatArgs);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/UsageException.java
// public class UsageException extends Exception {
// /**
// * @param message Message that will be shown to the user
// */
// public UsageException(String message) {
// super(message);
// }
// }
| import com.google.common.base.Joiner;
import eu.the5zig.mod.The5zigAPI;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandHandler;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandOutputPrinter;
import net.frozenbit.plugin5zig.cubecraft.commands.UsageException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import static java.lang.String.format; | package net.frozenbit.plugin5zig.cubecraft.commands.handlers;
public class RespondCommandHandler extends CommandHandler {
public static final int MSG_HISTORY_SIZE = 5;
private Deque<Message> messageHistory = new ArrayDeque<>();
public RespondCommandHandler() {
super("r", "Respond to the last message you have received");
}
@Override | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandHandler.java
// public abstract class CommandHandler {
// private final String name, description;
// private final String[] aliases;
//
// /**
// * Construct a new command. Must be registered with {@link CommandRegistry#register(CommandHandler)}
// *
// * @param name Name of the command. When the user types .name in the chat this command will be invoked
// * @param description Short description of what the command does.
// * @param aliases Aliases this command should also react to
// */
// public CommandHandler(String name, String description, String... aliases) {
// this.name = name;
// this.description = description;
// this.aliases = aliases;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String[] getAliases() {
// return aliases;
// }
//
// /**
// * Lice cycle method that gets called before the command is registered and ready to be invoked
// */
// public void onRegister() {
// }
//
// /**
// * Life cycle method that gets called after unregistering a command handler. Can be used to
// * clean up resources.
// */
// public void onUnregister() {
// }
//
// /**
// * Invoke this command and print the result to the user
// *
// * @param cmd Alias or name that was used by the user
// * @param args Arguments to this command, split on whitespaces. Does no do any complex parsing, like quotes.
// * @param printer Printer to write the output of this command to
// * @throws UsageException When the user gave invalid arguments. The message of the throwable will be printed to the user
// */
// public abstract void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException;
//
// /**
// * Show the usage of this command
// *
// * @param cmd Name or alias to show usage help for. If appropriate, the command can display a help for all aliases anyways.
// * @param printer Printer to write the help text to
// */
// public abstract void printUsage(String cmd, CommandOutputPrinter printer);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandOutputPrinter.java
// public interface CommandOutputPrinter {
// /**
// * Print an output message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter println(String msg, Object... formatArgs);
//
// /**
// * Print an error message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter printErrln(String msg, Object... formatArgs);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/UsageException.java
// public class UsageException extends Exception {
// /**
// * @param message Message that will be shown to the user
// */
// public UsageException(String message) {
// super(message);
// }
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/handlers/RespondCommandHandler.java
import com.google.common.base.Joiner;
import eu.the5zig.mod.The5zigAPI;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandHandler;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandOutputPrinter;
import net.frozenbit.plugin5zig.cubecraft.commands.UsageException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import static java.lang.String.format;
package net.frozenbit.plugin5zig.cubecraft.commands.handlers;
public class RespondCommandHandler extends CommandHandler {
public static final int MSG_HISTORY_SIZE = 5;
private Deque<Message> messageHistory = new ArrayDeque<>();
public RespondCommandHandler() {
super("r", "Respond to the last message you have received");
}
@Override | public void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException { |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/handlers/RespondCommandHandler.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandHandler.java
// public abstract class CommandHandler {
// private final String name, description;
// private final String[] aliases;
//
// /**
// * Construct a new command. Must be registered with {@link CommandRegistry#register(CommandHandler)}
// *
// * @param name Name of the command. When the user types .name in the chat this command will be invoked
// * @param description Short description of what the command does.
// * @param aliases Aliases this command should also react to
// */
// public CommandHandler(String name, String description, String... aliases) {
// this.name = name;
// this.description = description;
// this.aliases = aliases;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String[] getAliases() {
// return aliases;
// }
//
// /**
// * Lice cycle method that gets called before the command is registered and ready to be invoked
// */
// public void onRegister() {
// }
//
// /**
// * Life cycle method that gets called after unregistering a command handler. Can be used to
// * clean up resources.
// */
// public void onUnregister() {
// }
//
// /**
// * Invoke this command and print the result to the user
// *
// * @param cmd Alias or name that was used by the user
// * @param args Arguments to this command, split on whitespaces. Does no do any complex parsing, like quotes.
// * @param printer Printer to write the output of this command to
// * @throws UsageException When the user gave invalid arguments. The message of the throwable will be printed to the user
// */
// public abstract void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException;
//
// /**
// * Show the usage of this command
// *
// * @param cmd Name or alias to show usage help for. If appropriate, the command can display a help for all aliases anyways.
// * @param printer Printer to write the help text to
// */
// public abstract void printUsage(String cmd, CommandOutputPrinter printer);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandOutputPrinter.java
// public interface CommandOutputPrinter {
// /**
// * Print an output message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter println(String msg, Object... formatArgs);
//
// /**
// * Print an error message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter printErrln(String msg, Object... formatArgs);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/UsageException.java
// public class UsageException extends Exception {
// /**
// * @param message Message that will be shown to the user
// */
// public UsageException(String message) {
// super(message);
// }
// }
| import com.google.common.base.Joiner;
import eu.the5zig.mod.The5zigAPI;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandHandler;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandOutputPrinter;
import net.frozenbit.plugin5zig.cubecraft.commands.UsageException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import static java.lang.String.format; | package net.frozenbit.plugin5zig.cubecraft.commands.handlers;
public class RespondCommandHandler extends CommandHandler {
public static final int MSG_HISTORY_SIZE = 5;
private Deque<Message> messageHistory = new ArrayDeque<>();
public RespondCommandHandler() {
super("r", "Respond to the last message you have received");
}
@Override | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandHandler.java
// public abstract class CommandHandler {
// private final String name, description;
// private final String[] aliases;
//
// /**
// * Construct a new command. Must be registered with {@link CommandRegistry#register(CommandHandler)}
// *
// * @param name Name of the command. When the user types .name in the chat this command will be invoked
// * @param description Short description of what the command does.
// * @param aliases Aliases this command should also react to
// */
// public CommandHandler(String name, String description, String... aliases) {
// this.name = name;
// this.description = description;
// this.aliases = aliases;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String[] getAliases() {
// return aliases;
// }
//
// /**
// * Lice cycle method that gets called before the command is registered and ready to be invoked
// */
// public void onRegister() {
// }
//
// /**
// * Life cycle method that gets called after unregistering a command handler. Can be used to
// * clean up resources.
// */
// public void onUnregister() {
// }
//
// /**
// * Invoke this command and print the result to the user
// *
// * @param cmd Alias or name that was used by the user
// * @param args Arguments to this command, split on whitespaces. Does no do any complex parsing, like quotes.
// * @param printer Printer to write the output of this command to
// * @throws UsageException When the user gave invalid arguments. The message of the throwable will be printed to the user
// */
// public abstract void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException;
//
// /**
// * Show the usage of this command
// *
// * @param cmd Name or alias to show usage help for. If appropriate, the command can display a help for all aliases anyways.
// * @param printer Printer to write the help text to
// */
// public abstract void printUsage(String cmd, CommandOutputPrinter printer);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/CommandOutputPrinter.java
// public interface CommandOutputPrinter {
// /**
// * Print an output message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter println(String msg, Object... formatArgs);
//
// /**
// * Print an error message line
// *
// * @param msg Message
// * @param formatArgs optional format args. Used to {@link String#format(String, Object...) format} the message
// * @return This instance for easy chaining
// */
// CommandOutputPrinter printErrln(String msg, Object... formatArgs);
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/UsageException.java
// public class UsageException extends Exception {
// /**
// * @param message Message that will be shown to the user
// */
// public UsageException(String message) {
// super(message);
// }
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/handlers/RespondCommandHandler.java
import com.google.common.base.Joiner;
import eu.the5zig.mod.The5zigAPI;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandHandler;
import net.frozenbit.plugin5zig.cubecraft.commands.CommandOutputPrinter;
import net.frozenbit.plugin5zig.cubecraft.commands.UsageException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import static java.lang.String.format;
package net.frozenbit.plugin5zig.cubecraft.commands.handlers;
public class RespondCommandHandler extends CommandHandler {
public static final int MSG_HISTORY_SIZE = 5;
private Deque<Message> messageHistory = new ArrayDeque<>();
public RespondCommandHandler() {
super("r", "Respond to the last message you have received");
}
@Override | public void run(String cmd, List<String> args, CommandOutputPrinter printer) throws UsageException { |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/listeners/AbstractCubeCraftGameListener.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/CubeCraftGameMode.java
// public abstract class CubeCraftGameMode extends GameMode {
// protected List<CubeCraftPlayer> players = new CopyOnWriteArrayList<>();
// private String kit;
// private boolean kitsEnabled;
// private int pointsEarned;
//
// public CubeCraftPlayer getPlayerByName(String name) {
// for (CubeCraftPlayer player : players) {
// if (player.getName().equals(name)) {
// return player;
// }
// }
// return null;
// }
//
// /**
// * @return A list of players currently in this gamemode. The list can be modified, however
// * {@link #playerListUpdate()} MUST be called afterwards.
// */
// public List<CubeCraftPlayer> getPlayers() {
// return players;
// }
//
// public void playerListUpdate() {
// }
//
// public String getKit() {
// return kit;
// }
//
// public void setKit(String kit) {
// this.kit = kit;
// }
//
// public boolean hasKitsEnabled() {
// return kitsEnabled;
// }
//
// public void setKitsEnabled(boolean kitsEnabled) {
// this.kitsEnabled = kitsEnabled;
// }
//
// public int getPointsEarned() {
// return pointsEarned;
// }
//
// public void addPointsEarned(int pointsEarned) {
// this.pointsEarned += pointsEarned;
// }
//
// public boolean isStalkerEnabled() {
// return true;
// }
//
// /**
// * Return a singleton instance for the stalker of this gamemode. Before calling this method
// * always check {@link #isStalkerEnabled()}.
// * <p>
// * Implementing classes that do not need a stalker must overwrite {@link #isStalkerEnabled()}
// * and should throw an exception here.
// *
// * @return A stalker singleton.
// */
// public abstract Stalker getStalker();
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/VotableCubeCraftGameMode.java
// public abstract class VotableCubeCraftGameMode extends CubeCraftGameMode {
// private Table<CubeCraftPlayer, String, String> votes = HashBasedTable.create();
// private Map<String, String> draw = new HashMap<>();
// private TimeLootVotableMode.LootType chestType = TimeLootVotableMode.LootType.NONE;
// private long lastDrawResultTime;
// private ArrayList<String> formattedVoterList;
// private String formattedVoteResult;
//
// protected abstract String formatVoteString(CubeCraftPlayer player, Map<String, String> vote);
//
// protected abstract String formatVoteResult(Map<String, String> draw);
//
// protected abstract boolean isShownInVoterList(CubeCraftPlayer player);
//
// protected abstract String[] getVoteCategories();
//
// public final long getVoteResultTime() {
// return lastDrawResultTime;
// }
//
// public final String getVoteResult() {
// if (formattedVoteResult == null) {
// formattedVoteResult = isDrawDone() ? formatVoteResult(Collections.unmodifiableMap(draw)) : "";
// }
// return formattedVoteResult;
// }
//
// public boolean isDrawDone() {
// for (String category : getVoteCategories()) {
// if (!draw.containsKey(category)) {
// return false;
// }
// }
// return true;
// }
//
// public final List<String> getFormattedVoterList() {
// if (formattedVoterList == null) {
// formattedVoterList = new ArrayList<>();
// for (CubeCraftPlayer player : players) {
// if (isShownInVoterList(player)) {
// formattedVoterList.add(formatVoteString(player, votes.row(player)));
// }
// }
// }
// return formattedVoterList;
// }
//
// @Override
// public void playerListUpdate() {
// super.playerListUpdate();
// formattedVoterList = null;
// }
//
// public final void onDrawResult(String category, String vote) {
// draw.put(category, vote);
// lastDrawResultTime = System.currentTimeMillis();
// formattedVoteResult = null;
// }
//
// public final void onVote(String playerName, String category, String vote) {
// CubeCraftPlayer voter = getPlayerByName(playerName);
// votes.put(voter, category, vote);
// formattedVoterList = null;
// }
//
// }
| import com.google.common.base.Splitter;
import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.mod.server.GameState;
import eu.the5zig.mod.server.IPatternResult;
import eu.the5zig.mod.util.NetworkPlayerInfo;
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.*;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.CubeCraftGameMode;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.VotableCubeCraftGameMode;
import java.util.*;
import java.util.regex.Pattern;
import static java.lang.String.format; | }
if (gameMode.isStalkerEnabled()) {
gameMode.getStalker().onKill(match.get(0), match.get(1));
}
break;
}
case "points":
gameMode.addPointsEarned(Integer.parseInt(match.get(0)));
break;
case "playerList":
updatePlayerList(gameMode, match);
if (gameMode.isStalkerEnabled()) {
gameMode.getStalker().onPlayerListUpdate(gameMode.getPlayers());
}
break;
case "selfWin":
case "selfDeath": {
if (!summaryShown) {
summaryShown = true;
long gameTime = (System.currentTimeMillis() - gameMode.getTime()) / 1000;
long minutes = gameTime / 60;
long seconds = gameTime % 60;
The5zigAPI.getAPI().messagePlayer(
format("%sGame ended after %d:%02d! You killed %d players and earned %d points ",
ChatColor.GOLD, minutes, seconds, gameMode.getKills(),
gameMode.getPointsEarned()));
}
break;
}
case "vote": { | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/CubeCraftGameMode.java
// public abstract class CubeCraftGameMode extends GameMode {
// protected List<CubeCraftPlayer> players = new CopyOnWriteArrayList<>();
// private String kit;
// private boolean kitsEnabled;
// private int pointsEarned;
//
// public CubeCraftPlayer getPlayerByName(String name) {
// for (CubeCraftPlayer player : players) {
// if (player.getName().equals(name)) {
// return player;
// }
// }
// return null;
// }
//
// /**
// * @return A list of players currently in this gamemode. The list can be modified, however
// * {@link #playerListUpdate()} MUST be called afterwards.
// */
// public List<CubeCraftPlayer> getPlayers() {
// return players;
// }
//
// public void playerListUpdate() {
// }
//
// public String getKit() {
// return kit;
// }
//
// public void setKit(String kit) {
// this.kit = kit;
// }
//
// public boolean hasKitsEnabled() {
// return kitsEnabled;
// }
//
// public void setKitsEnabled(boolean kitsEnabled) {
// this.kitsEnabled = kitsEnabled;
// }
//
// public int getPointsEarned() {
// return pointsEarned;
// }
//
// public void addPointsEarned(int pointsEarned) {
// this.pointsEarned += pointsEarned;
// }
//
// public boolean isStalkerEnabled() {
// return true;
// }
//
// /**
// * Return a singleton instance for the stalker of this gamemode. Before calling this method
// * always check {@link #isStalkerEnabled()}.
// * <p>
// * Implementing classes that do not need a stalker must overwrite {@link #isStalkerEnabled()}
// * and should throw an exception here.
// *
// * @return A stalker singleton.
// */
// public abstract Stalker getStalker();
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/VotableCubeCraftGameMode.java
// public abstract class VotableCubeCraftGameMode extends CubeCraftGameMode {
// private Table<CubeCraftPlayer, String, String> votes = HashBasedTable.create();
// private Map<String, String> draw = new HashMap<>();
// private TimeLootVotableMode.LootType chestType = TimeLootVotableMode.LootType.NONE;
// private long lastDrawResultTime;
// private ArrayList<String> formattedVoterList;
// private String formattedVoteResult;
//
// protected abstract String formatVoteString(CubeCraftPlayer player, Map<String, String> vote);
//
// protected abstract String formatVoteResult(Map<String, String> draw);
//
// protected abstract boolean isShownInVoterList(CubeCraftPlayer player);
//
// protected abstract String[] getVoteCategories();
//
// public final long getVoteResultTime() {
// return lastDrawResultTime;
// }
//
// public final String getVoteResult() {
// if (formattedVoteResult == null) {
// formattedVoteResult = isDrawDone() ? formatVoteResult(Collections.unmodifiableMap(draw)) : "";
// }
// return formattedVoteResult;
// }
//
// public boolean isDrawDone() {
// for (String category : getVoteCategories()) {
// if (!draw.containsKey(category)) {
// return false;
// }
// }
// return true;
// }
//
// public final List<String> getFormattedVoterList() {
// if (formattedVoterList == null) {
// formattedVoterList = new ArrayList<>();
// for (CubeCraftPlayer player : players) {
// if (isShownInVoterList(player)) {
// formattedVoterList.add(formatVoteString(player, votes.row(player)));
// }
// }
// }
// return formattedVoterList;
// }
//
// @Override
// public void playerListUpdate() {
// super.playerListUpdate();
// formattedVoterList = null;
// }
//
// public final void onDrawResult(String category, String vote) {
// draw.put(category, vote);
// lastDrawResultTime = System.currentTimeMillis();
// formattedVoteResult = null;
// }
//
// public final void onVote(String playerName, String category, String vote) {
// CubeCraftPlayer voter = getPlayerByName(playerName);
// votes.put(voter, category, vote);
// formattedVoterList = null;
// }
//
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/listeners/AbstractCubeCraftGameListener.java
import com.google.common.base.Splitter;
import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.mod.server.GameState;
import eu.the5zig.mod.server.IPatternResult;
import eu.the5zig.mod.util.NetworkPlayerInfo;
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.*;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.CubeCraftGameMode;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.VotableCubeCraftGameMode;
import java.util.*;
import java.util.regex.Pattern;
import static java.lang.String.format;
}
if (gameMode.isStalkerEnabled()) {
gameMode.getStalker().onKill(match.get(0), match.get(1));
}
break;
}
case "points":
gameMode.addPointsEarned(Integer.parseInt(match.get(0)));
break;
case "playerList":
updatePlayerList(gameMode, match);
if (gameMode.isStalkerEnabled()) {
gameMode.getStalker().onPlayerListUpdate(gameMode.getPlayers());
}
break;
case "selfWin":
case "selfDeath": {
if (!summaryShown) {
summaryShown = true;
long gameTime = (System.currentTimeMillis() - gameMode.getTime()) / 1000;
long minutes = gameTime / 60;
long seconds = gameTime % 60;
The5zigAPI.getAPI().messagePlayer(
format("%sGame ended after %d:%02d! You killed %d players and earned %d points ",
ChatColor.GOLD, minutes, seconds, gameMode.getKills(),
gameMode.getPointsEarned()));
}
break;
}
case "vote": { | if (gameMode instanceof VotableCubeCraftGameMode) { |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/items/StalkerItem.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/CubeCraftGameMode.java
// public abstract class CubeCraftGameMode extends GameMode {
// protected List<CubeCraftPlayer> players = new CopyOnWriteArrayList<>();
// private String kit;
// private boolean kitsEnabled;
// private int pointsEarned;
//
// public CubeCraftPlayer getPlayerByName(String name) {
// for (CubeCraftPlayer player : players) {
// if (player.getName().equals(name)) {
// return player;
// }
// }
// return null;
// }
//
// /**
// * @return A list of players currently in this gamemode. The list can be modified, however
// * {@link #playerListUpdate()} MUST be called afterwards.
// */
// public List<CubeCraftPlayer> getPlayers() {
// return players;
// }
//
// public void playerListUpdate() {
// }
//
// public String getKit() {
// return kit;
// }
//
// public void setKit(String kit) {
// this.kit = kit;
// }
//
// public boolean hasKitsEnabled() {
// return kitsEnabled;
// }
//
// public void setKitsEnabled(boolean kitsEnabled) {
// this.kitsEnabled = kitsEnabled;
// }
//
// public int getPointsEarned() {
// return pointsEarned;
// }
//
// public void addPointsEarned(int pointsEarned) {
// this.pointsEarned += pointsEarned;
// }
//
// public boolean isStalkerEnabled() {
// return true;
// }
//
// /**
// * Return a singleton instance for the stalker of this gamemode. Before calling this method
// * always check {@link #isStalkerEnabled()}.
// * <p>
// * Implementing classes that do not need a stalker must overwrite {@link #isStalkerEnabled()}
// * and should throw an exception here.
// *
// * @return A stalker singleton.
// */
// public abstract Stalker getStalker();
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/StalkedPlayer.java
// public class StalkedPlayer {
// private int kills, deaths;
// private CubeCraftPlayer cubeCraftPlayer;
//
// public StalkedPlayer(CubeCraftPlayer cubeCraftPlayer, int kills, int deaths) {
// this.cubeCraftPlayer = cubeCraftPlayer;
// this.kills = kills;
// this.deaths = deaths;
// }
//
// public StalkedPlayer(CubeCraftPlayer cubeCraftPlayer, JSONObject playerData) {
// this.cubeCraftPlayer = cubeCraftPlayer;
// kills = playerData.getInt("kills");
// deaths = playerData.getInt("deaths");
// }
//
// public String getName() {
// return cubeCraftPlayer.getName();
// }
//
// public UUID getId() {
// return cubeCraftPlayer.getId();
// }
//
// public int getKills() {
// return kills;
// }
//
// public void onKill() {
// ++kills;
// }
//
// public int getDeaths() {
// return deaths;
// }
//
// public void onDeath() {
// ++deaths;
// }
//
// public int getThreat() {
// return deaths - kills;
// }
//
// public ChatColor getThreatColor() {
// if (getThreat() <= 0)
// return ChatColor.WHITE;
// else if (getThreat() <= 3)
// return ChatColor.YELLOW;
// else
// return ChatColor.RED;
// }
//
// public JSONObject toJSON() {
// JSONObject playerData = new JSONObject();
// playerData.put("kills", kills);
// playerData.put("deaths", deaths);
// return playerData;
// }
// }
| import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.mod.modules.GameModeItem;
import eu.the5zig.mod.render.RenderLocation;
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.CubeCraftGameMode;
import net.frozenbit.plugin5zig.cubecraft.stalker.StalkedPlayer;
import java.util.List; | package net.frozenbit.plugin5zig.cubecraft.items;
public class StalkerItem extends GameModeItem<CubeCraftGameMode> {
private final static int minWidthName = 100;
private final static int widthKills = 30;
private final static int widthDeaths = 40;
private int widthName;
public StalkerItem() {
super(CubeCraftGameMode.class);
}
@Override
public void render(int x, int y, RenderLocation renderLocation, boolean dummy) {
if (dummy) {
renderDummyStalker(x, y);
return;
}
widthName = Math.max(minWidthName, getGameMode().getStalker().getMaxNameWidth() + 20); | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/gamemodes/CubeCraftGameMode.java
// public abstract class CubeCraftGameMode extends GameMode {
// protected List<CubeCraftPlayer> players = new CopyOnWriteArrayList<>();
// private String kit;
// private boolean kitsEnabled;
// private int pointsEarned;
//
// public CubeCraftPlayer getPlayerByName(String name) {
// for (CubeCraftPlayer player : players) {
// if (player.getName().equals(name)) {
// return player;
// }
// }
// return null;
// }
//
// /**
// * @return A list of players currently in this gamemode. The list can be modified, however
// * {@link #playerListUpdate()} MUST be called afterwards.
// */
// public List<CubeCraftPlayer> getPlayers() {
// return players;
// }
//
// public void playerListUpdate() {
// }
//
// public String getKit() {
// return kit;
// }
//
// public void setKit(String kit) {
// this.kit = kit;
// }
//
// public boolean hasKitsEnabled() {
// return kitsEnabled;
// }
//
// public void setKitsEnabled(boolean kitsEnabled) {
// this.kitsEnabled = kitsEnabled;
// }
//
// public int getPointsEarned() {
// return pointsEarned;
// }
//
// public void addPointsEarned(int pointsEarned) {
// this.pointsEarned += pointsEarned;
// }
//
// public boolean isStalkerEnabled() {
// return true;
// }
//
// /**
// * Return a singleton instance for the stalker of this gamemode. Before calling this method
// * always check {@link #isStalkerEnabled()}.
// * <p>
// * Implementing classes that do not need a stalker must overwrite {@link #isStalkerEnabled()}
// * and should throw an exception here.
// *
// * @return A stalker singleton.
// */
// public abstract Stalker getStalker();
// }
//
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/StalkedPlayer.java
// public class StalkedPlayer {
// private int kills, deaths;
// private CubeCraftPlayer cubeCraftPlayer;
//
// public StalkedPlayer(CubeCraftPlayer cubeCraftPlayer, int kills, int deaths) {
// this.cubeCraftPlayer = cubeCraftPlayer;
// this.kills = kills;
// this.deaths = deaths;
// }
//
// public StalkedPlayer(CubeCraftPlayer cubeCraftPlayer, JSONObject playerData) {
// this.cubeCraftPlayer = cubeCraftPlayer;
// kills = playerData.getInt("kills");
// deaths = playerData.getInt("deaths");
// }
//
// public String getName() {
// return cubeCraftPlayer.getName();
// }
//
// public UUID getId() {
// return cubeCraftPlayer.getId();
// }
//
// public int getKills() {
// return kills;
// }
//
// public void onKill() {
// ++kills;
// }
//
// public int getDeaths() {
// return deaths;
// }
//
// public void onDeath() {
// ++deaths;
// }
//
// public int getThreat() {
// return deaths - kills;
// }
//
// public ChatColor getThreatColor() {
// if (getThreat() <= 0)
// return ChatColor.WHITE;
// else if (getThreat() <= 3)
// return ChatColor.YELLOW;
// else
// return ChatColor.RED;
// }
//
// public JSONObject toJSON() {
// JSONObject playerData = new JSONObject();
// playerData.put("kills", kills);
// playerData.put("deaths", deaths);
// return playerData;
// }
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/items/StalkerItem.java
import eu.the5zig.mod.The5zigAPI;
import eu.the5zig.mod.modules.GameModeItem;
import eu.the5zig.mod.render.RenderLocation;
import eu.the5zig.util.minecraft.ChatColor;
import net.frozenbit.plugin5zig.cubecraft.gamemodes.CubeCraftGameMode;
import net.frozenbit.plugin5zig.cubecraft.stalker.StalkedPlayer;
import java.util.List;
package net.frozenbit.plugin5zig.cubecraft.items;
public class StalkerItem extends GameModeItem<CubeCraftGameMode> {
private final static int minWidthName = 100;
private final static int widthKills = 30;
private final static int widthDeaths = 40;
private int widthName;
public StalkerItem() {
super(CubeCraftGameMode.class);
}
@Override
public void render(int x, int y, RenderLocation renderLocation, boolean dummy) {
if (dummy) {
renderDummyStalker(x, y);
return;
}
widthName = Math.max(minWidthName, getGameMode().getStalker().getMaxNameWidth() + 20); | List<StalkedPlayer> stalkedPlayers = getGameMode().getStalker().getStalkedPlayerList(); |
nullEuro/5zigCubecraft | src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/stalker/MojangResponseHandler.java | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/Util.java
// public class Util {
// /**
// * Gson instance that can parse data returned from the Mojang API.
// */
// public static final Gson GSON = new GsonBuilder()
// .registerTypeAdapter(UUID.class, new UUIDTypeAdapter().nullSafe())
// .create();
//
// public static String extractGroup(String string, Pattern pattern, int group) {
// Matcher matcher = pattern.matcher(string);
// return matcher.matches() ? matcher.group(group) : null;
// }
//
// public static class LoggingRunnable implements Runnable {
// private final Runnable delegate;
//
// public LoggingRunnable(Runnable delegate) {
// this.delegate = delegate;
// }
//
// @Override
// public final void run() {
// try {
// delegate.run();
// } catch (RuntimeException e) {
// The5zigAPI.getLogger().error("Error in thread " + Thread.currentThread().getName(), e);
// throw e;
// }
// }
// }
//
// /**
// * Adapter that works with dashless UUIDs as retured by the Mojang API.
// */
// private static class UUIDTypeAdapter extends TypeAdapter<UUID> {
// @Override
// public void write(JsonWriter out, UUID value) throws IOException {
// out.value(value.toString().replaceAll("-", ""));
// }
//
// @Override
// public UUID read(JsonReader in) throws IOException {
// String stringId = in.nextString();
// return new UUID(
// new BigInteger(stringId.substring(0, 16), 16).longValue(),
// new BigInteger(stringId.substring(16), 16).longValue());
// }
// }
//
// }
| import com.google.gson.reflect.TypeToken;
import net.frozenbit.plugin5zig.cubecraft.Util;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.List; | package net.frozenbit.plugin5zig.cubecraft.commands.stalker;
public class MojangResponseHandler implements ResponseHandler<List<UserData>> {
private static final TypeToken<List<UserData>> RESPONSE_TYPE = new TypeToken<List<UserData>>() {
};
@Override
public List<UserData> handleResponse(HttpResponse response) throws IOException {
StatusLine statusLine = response.getStatusLine();
HttpEntity entity = response.getEntity();
if (statusLine.getStatusCode() >= 300) {
throw new HttpResponseException(
statusLine.getStatusCode(),
statusLine.getReasonPhrase());
}
if (entity == null) {
throw new ClientProtocolException("Response contains no content");
}
String jsonResponseStr = EntityUtils.toString(entity); | // Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/Util.java
// public class Util {
// /**
// * Gson instance that can parse data returned from the Mojang API.
// */
// public static final Gson GSON = new GsonBuilder()
// .registerTypeAdapter(UUID.class, new UUIDTypeAdapter().nullSafe())
// .create();
//
// public static String extractGroup(String string, Pattern pattern, int group) {
// Matcher matcher = pattern.matcher(string);
// return matcher.matches() ? matcher.group(group) : null;
// }
//
// public static class LoggingRunnable implements Runnable {
// private final Runnable delegate;
//
// public LoggingRunnable(Runnable delegate) {
// this.delegate = delegate;
// }
//
// @Override
// public final void run() {
// try {
// delegate.run();
// } catch (RuntimeException e) {
// The5zigAPI.getLogger().error("Error in thread " + Thread.currentThread().getName(), e);
// throw e;
// }
// }
// }
//
// /**
// * Adapter that works with dashless UUIDs as retured by the Mojang API.
// */
// private static class UUIDTypeAdapter extends TypeAdapter<UUID> {
// @Override
// public void write(JsonWriter out, UUID value) throws IOException {
// out.value(value.toString().replaceAll("-", ""));
// }
//
// @Override
// public UUID read(JsonReader in) throws IOException {
// String stringId = in.nextString();
// return new UUID(
// new BigInteger(stringId.substring(0, 16), 16).longValue(),
// new BigInteger(stringId.substring(16), 16).longValue());
// }
// }
//
// }
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/stalker/MojangResponseHandler.java
import com.google.gson.reflect.TypeToken;
import net.frozenbit.plugin5zig.cubecraft.Util;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.List;
package net.frozenbit.plugin5zig.cubecraft.commands.stalker;
public class MojangResponseHandler implements ResponseHandler<List<UserData>> {
private static final TypeToken<List<UserData>> RESPONSE_TYPE = new TypeToken<List<UserData>>() {
};
@Override
public List<UserData> handleResponse(HttpResponse response) throws IOException {
StatusLine statusLine = response.getStatusLine();
HttpEntity entity = response.getEntity();
if (statusLine.getStatusCode() >= 300) {
throw new HttpResponseException(
statusLine.getStatusCode(),
statusLine.getReasonPhrase());
}
if (entity == null) {
throw new ClientProtocolException("Response contains no content");
}
String jsonResponseStr = EntityUtils.toString(entity); | return Util.GSON.fromJson(jsonResponseStr, RESPONSE_TYPE.getType()); |
HarryPotterSpells/HarryPotterSpells | src/com/hpspells/core/SpellTargeter.java | // Path: src/com/hpspells/core/util/FireworkEffectPlayer.java
// public class FireworkEffectPlayer {
//
// /*
// * Example use:
// *
// * public class FireWorkPlugin implements Listener {
// *
// * FireworkEffectPlayer fplayer = new FireworkEffectPlayer();
// *
// * @EventHandler
// * public void onPlayerLogin(PlayerLoginEvent event) {
// * fplayer.playFirework(event.getPlayer().getWorld(), event.getPlayer.getLocation(), Util.getRandomFireworkEffect());
// * }
// *
// * }
// */
//
// // internal references, performance improvements
// private static Method world_getHandle = null, nms_world_broadcastEntityEffect = null, firework_getHandle = null;
//
// /**
// * Play a pretty firework at the location with the FireworkEffect when called
// *
// * @param world
// * @param loc
// * @param fe
// * @throws Exception
// */
// public static void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
// // Bukkity load (CraftFirework)
// Firework fw = (Firework) world.spawn(loc, Firework.class);
// // the net.minecraft.server.World
// Object nms_world = null;
// Object nms_firework = null;
// /*
// * The reflection part, this gives us access to funky ways of messing around with things
// */
// if (world_getHandle == null) {
// // get the methods of the craftbukkit objects
// world_getHandle = getMethod(world.getClass(), "getHandle");
// firework_getHandle = getMethod(fw.getClass(), "getHandle");
// }
// // invoke with no arguments
// nms_world = world_getHandle.invoke(world, (Object[]) null);
// nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
// // null checks are fast, so having this seperate is ok
// if (nms_world_broadcastEntityEffect == null) {
// // get the method of the nms_world
// nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect");
// }
// /*
// * Now we mess with the metadata, allowing nice clean spawning of a pretty firework (look, pretty lights!)
// */
// // metadata load
// FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
// // clear existing
// data.clearEffects();
// // power of one
// data.setPower(1);
// // add the effect
// data.addEffect(fe);
// // set the meta
// fw.setFireworkMeta(data);
// /*
// * Finally, we broadcast the entity effect then kill our fireworks object
// */
// // invoke with arguments
// nms_world_broadcastEntityEffect.invoke(nms_world, new Object[]{nms_firework, (byte) 17});
// // remove from the game
// fw.remove();
// }
//
// /**
// * Fires a firework with an effect at the location specified with a certain power.
// *
// * @param location Location to fire
// * @param effect Effects that the fireworks should have
// * @param power The amount of power the firework should have
// * @see #playFirework(Location, FireworkEffect)
// */
// public static void playFirework(Location location, FireworkEffect effect, int power) {
// Firework fw = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
// FireworkMeta fwm = fw.getFireworkMeta();
//
// fwm.setPower(power);
// fwm.addEffect(effect);
//
// fw.setFireworkMeta(fwm);
// }
//
// /**
// * Fires a firework with an effect at the location specified with a power of 1.
// *
// * @param location Location to fire
// * @param effect Effects that the fireworks should have
// */
// public static void playFirework(Location location, FireworkEffect effect) {
// playFirework(location, effect, 1);
// }
//
// }
//
// Path: src/com/hpspells/core/util/HPSParticle.java
// public class HPSParticle {
//
// private Particle particle;
// private DustOptions options;
//
// public HPSParticle(Particle particle) {
// this(particle, null);
// }
//
// public HPSParticle(Particle particle, DustOptions options) {
// this.particle = particle;
// this.options = options;
// }
//
// public Particle getParticle() {
// return particle;
// }
//
// public void setParticle(Particle particle) {
// this.particle = particle;
// }
//
// public DustOptions getOptions() {
// return options;
// }
//
// public void setOptions(DustOptions options) {
// this.options = options;
// }
//
// }
| import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Particle.DustOptions;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.hpspells.core.util.FireworkEffectPlayer;
import com.hpspells.core.util.HPSParticle; | }
if (!loc.getBlock().getType().isTransparent()) {
onHit.hitBlock(loc.getBlock());
cancel();
return;
}
List<LivingEntity> list = getNearbyEntities(loc, 2, caster);
if (list.size() != 0) {
onHit.hitEntity(list.get(0));
cancel();
return;
}
tickTracker++;
if (tickTracker > maxTicks && !(maxTicks == -1)) {
cancel();
}
}
}.run();
}
/**
* Registers a new {@link SpellHitEvent} to be called when a spell hits something using the default offset and count.
*
* @param caster the player who cast the spell
* @param onHit the SpellHitEvent to call when the spell hits something
* @param spellSpeed the vector multiplier for the movement of the spell
* @param hpsParticle the {@link HPSParticle} to play during the movement of the spell
*/ | // Path: src/com/hpspells/core/util/FireworkEffectPlayer.java
// public class FireworkEffectPlayer {
//
// /*
// * Example use:
// *
// * public class FireWorkPlugin implements Listener {
// *
// * FireworkEffectPlayer fplayer = new FireworkEffectPlayer();
// *
// * @EventHandler
// * public void onPlayerLogin(PlayerLoginEvent event) {
// * fplayer.playFirework(event.getPlayer().getWorld(), event.getPlayer.getLocation(), Util.getRandomFireworkEffect());
// * }
// *
// * }
// */
//
// // internal references, performance improvements
// private static Method world_getHandle = null, nms_world_broadcastEntityEffect = null, firework_getHandle = null;
//
// /**
// * Play a pretty firework at the location with the FireworkEffect when called
// *
// * @param world
// * @param loc
// * @param fe
// * @throws Exception
// */
// public static void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
// // Bukkity load (CraftFirework)
// Firework fw = (Firework) world.spawn(loc, Firework.class);
// // the net.minecraft.server.World
// Object nms_world = null;
// Object nms_firework = null;
// /*
// * The reflection part, this gives us access to funky ways of messing around with things
// */
// if (world_getHandle == null) {
// // get the methods of the craftbukkit objects
// world_getHandle = getMethod(world.getClass(), "getHandle");
// firework_getHandle = getMethod(fw.getClass(), "getHandle");
// }
// // invoke with no arguments
// nms_world = world_getHandle.invoke(world, (Object[]) null);
// nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
// // null checks are fast, so having this seperate is ok
// if (nms_world_broadcastEntityEffect == null) {
// // get the method of the nms_world
// nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect");
// }
// /*
// * Now we mess with the metadata, allowing nice clean spawning of a pretty firework (look, pretty lights!)
// */
// // metadata load
// FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
// // clear existing
// data.clearEffects();
// // power of one
// data.setPower(1);
// // add the effect
// data.addEffect(fe);
// // set the meta
// fw.setFireworkMeta(data);
// /*
// * Finally, we broadcast the entity effect then kill our fireworks object
// */
// // invoke with arguments
// nms_world_broadcastEntityEffect.invoke(nms_world, new Object[]{nms_firework, (byte) 17});
// // remove from the game
// fw.remove();
// }
//
// /**
// * Fires a firework with an effect at the location specified with a certain power.
// *
// * @param location Location to fire
// * @param effect Effects that the fireworks should have
// * @param power The amount of power the firework should have
// * @see #playFirework(Location, FireworkEffect)
// */
// public static void playFirework(Location location, FireworkEffect effect, int power) {
// Firework fw = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
// FireworkMeta fwm = fw.getFireworkMeta();
//
// fwm.setPower(power);
// fwm.addEffect(effect);
//
// fw.setFireworkMeta(fwm);
// }
//
// /**
// * Fires a firework with an effect at the location specified with a power of 1.
// *
// * @param location Location to fire
// * @param effect Effects that the fireworks should have
// */
// public static void playFirework(Location location, FireworkEffect effect) {
// playFirework(location, effect, 1);
// }
//
// }
//
// Path: src/com/hpspells/core/util/HPSParticle.java
// public class HPSParticle {
//
// private Particle particle;
// private DustOptions options;
//
// public HPSParticle(Particle particle) {
// this(particle, null);
// }
//
// public HPSParticle(Particle particle, DustOptions options) {
// this.particle = particle;
// this.options = options;
// }
//
// public Particle getParticle() {
// return particle;
// }
//
// public void setParticle(Particle particle) {
// this.particle = particle;
// }
//
// public DustOptions getOptions() {
// return options;
// }
//
// public void setOptions(DustOptions options) {
// this.options = options;
// }
//
// }
// Path: src/com/hpspells/core/SpellTargeter.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Particle.DustOptions;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.hpspells.core.util.FireworkEffectPlayer;
import com.hpspells.core.util.HPSParticle;
}
if (!loc.getBlock().getType().isTransparent()) {
onHit.hitBlock(loc.getBlock());
cancel();
return;
}
List<LivingEntity> list = getNearbyEntities(loc, 2, caster);
if (list.size() != 0) {
onHit.hitEntity(list.get(0));
cancel();
return;
}
tickTracker++;
if (tickTracker > maxTicks && !(maxTicks == -1)) {
cancel();
}
}
}.run();
}
/**
* Registers a new {@link SpellHitEvent} to be called when a spell hits something using the default offset and count.
*
* @param caster the player who cast the spell
* @param onHit the SpellHitEvent to call when the spell hits something
* @param spellSpeed the vector multiplier for the movement of the spell
* @param hpsParticle the {@link HPSParticle} to play during the movement of the spell
*/ | public void register(final Player caster, final SpellHitEvent onHit, final double spellSpeed, final HPSParticle hpsParticle) { |
HarryPotterSpells/HarryPotterSpells | src/com/hpspells/core/spell/Obliviate.java | // Path: src/com/hpspells/core/SpellTargeter.java
// public interface SpellHitEvent {
//
// /**
// * Called when a spell has hit a block
// *
// * @param block the block it hit
// */
// void hitBlock(Block block);
//
// /**
// * Called when a spell has hit an entity
// *
// * @param entity the entity it hit
// */
// void hitEntity(LivingEntity entity);
//
// }
| import org.bukkit.Particle;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.hpspells.core.SpellTargeter.SpellHitEvent; | package com.hpspells.core.spell;
public class Obliviate extends Spell {
public Obliviate(com.hpspells.core.HPS instance) {
super(instance);
}
@Override
public boolean cast(final Player p) { | // Path: src/com/hpspells/core/SpellTargeter.java
// public interface SpellHitEvent {
//
// /**
// * Called when a spell has hit a block
// *
// * @param block the block it hit
// */
// void hitBlock(Block block);
//
// /**
// * Called when a spell has hit an entity
// *
// * @param entity the entity it hit
// */
// void hitEntity(LivingEntity entity);
//
// }
// Path: src/com/hpspells/core/spell/Obliviate.java
import org.bukkit.Particle;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.hpspells.core.SpellTargeter.SpellHitEvent;
package com.hpspells.core.spell;
public class Obliviate extends Spell {
public Obliviate(com.hpspells.core.HPS instance) {
super(instance);
}
@Override
public boolean cast(final Player p) { | HPS.SpellTargeter.register(p, new SpellHitEvent() { |
HarryPotterSpells/HarryPotterSpells | src/com/hpspells/core/api/event/SpellBookRecipeAddEvent.java | // Path: src/com/hpspells/core/api/SpellBookRecipe.java
// public class SpellBookRecipe implements Recipe {
// public static final String[] RANDOM_AUTHORS = new String[]{"Merwyn the Malicious", "Delfina Crimp", "Felix Summerbee", "Jarleth Hobart", "Mnemone Radford", "Urquhart Rackharrow", "Orabella Nuttley", "Levina Monkstanley", "Elliot Smethwyck", "Basil Horton", "Randolph Keitch", "Miranda Goshawk", "Tom Riddle", "Severus Snape", "Fred Weasley", "George Weasley", "Unknown"};
//
// private ShapedRecipe recipe;
// private HPS HPS;
//
// /**
// * Constructs a new {@link SpellBookRecipe}
// *
// * @param spell the {@link Spell} that this recipe will create a book for
// * @param if {@code true} the recipe will be shapeless
// */
// public SpellBookRecipe(HPS instance, Spell spell) {
// this.HPS = instance;
//
// ItemStack stack = new ItemStack(Material.WRITTEN_BOOK);
//
// BookMeta meta = (BookMeta) stack.getItemMeta();
// meta.setTitle(spell.getName());
// meta.addPage(spell.getDescription());
// meta.setAuthor(getRandomAuthor());
// stack.setItemMeta(meta);
//
// try {
// stack = MiscUtilities.makeGlow(stack);
// } catch (Exception e) {
// HPS.PM.log(Level.WARNING, HPS.Localisation.getTranslation("errEnchantmentEffect"));
// HPS.PM.debug(e);
// }
//
// recipe = new ShapedRecipe(new NamespacedKey(HPS, "spellbook"), stack);
// }
//
// /**
// * {@inheritDoc ShapedRecipe#shape(String...)}
// */
// public void shape(String... rows) {
// recipe.shape(rows);
// }
//
// /**
// * {@inheritDoc ShapedRecipe#setIngredient(char, Material)}
// */
// public void setIngredient(char key, Material ingredient) {
// recipe.setIngredient(key, ingredient);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public ItemStack getResult() {
// return recipe.getResult();
// }
//
// /**
// * Gets a random spell author from {@link SpellBookRecipe#RANDOM_AUTHORS}
// *
// * @return a random spell author
// */
// public static String getRandomAuthor() {
// return RANDOM_AUTHORS[new Random().nextInt(RANDOM_AUTHORS.length)];
// }
//
// }
| import com.hpspells.core.api.SpellBookRecipe;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; | package com.hpspells.core.api.event;
/**
* An event called just before a {@link SpellBookRecipe} is added to the server
*/
public class SpellBookRecipeAddEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
| // Path: src/com/hpspells/core/api/SpellBookRecipe.java
// public class SpellBookRecipe implements Recipe {
// public static final String[] RANDOM_AUTHORS = new String[]{"Merwyn the Malicious", "Delfina Crimp", "Felix Summerbee", "Jarleth Hobart", "Mnemone Radford", "Urquhart Rackharrow", "Orabella Nuttley", "Levina Monkstanley", "Elliot Smethwyck", "Basil Horton", "Randolph Keitch", "Miranda Goshawk", "Tom Riddle", "Severus Snape", "Fred Weasley", "George Weasley", "Unknown"};
//
// private ShapedRecipe recipe;
// private HPS HPS;
//
// /**
// * Constructs a new {@link SpellBookRecipe}
// *
// * @param spell the {@link Spell} that this recipe will create a book for
// * @param if {@code true} the recipe will be shapeless
// */
// public SpellBookRecipe(HPS instance, Spell spell) {
// this.HPS = instance;
//
// ItemStack stack = new ItemStack(Material.WRITTEN_BOOK);
//
// BookMeta meta = (BookMeta) stack.getItemMeta();
// meta.setTitle(spell.getName());
// meta.addPage(spell.getDescription());
// meta.setAuthor(getRandomAuthor());
// stack.setItemMeta(meta);
//
// try {
// stack = MiscUtilities.makeGlow(stack);
// } catch (Exception e) {
// HPS.PM.log(Level.WARNING, HPS.Localisation.getTranslation("errEnchantmentEffect"));
// HPS.PM.debug(e);
// }
//
// recipe = new ShapedRecipe(new NamespacedKey(HPS, "spellbook"), stack);
// }
//
// /**
// * {@inheritDoc ShapedRecipe#shape(String...)}
// */
// public void shape(String... rows) {
// recipe.shape(rows);
// }
//
// /**
// * {@inheritDoc ShapedRecipe#setIngredient(char, Material)}
// */
// public void setIngredient(char key, Material ingredient) {
// recipe.setIngredient(key, ingredient);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public ItemStack getResult() {
// return recipe.getResult();
// }
//
// /**
// * Gets a random spell author from {@link SpellBookRecipe#RANDOM_AUTHORS}
// *
// * @return a random spell author
// */
// public static String getRandomAuthor() {
// return RANDOM_AUTHORS[new Random().nextInt(RANDOM_AUTHORS.length)];
// }
//
// }
// Path: src/com/hpspells/core/api/event/SpellBookRecipeAddEvent.java
import com.hpspells.core.api.SpellBookRecipe;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
package com.hpspells.core.api.event;
/**
* An event called just before a {@link SpellBookRecipe} is added to the server
*/
public class SpellBookRecipeAddEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
| private SpellBookRecipe recipe; |
HarryPotterSpells/HarryPotterSpells | src/com/hpspells/core/util/MiscUtilities.java | // Path: src/com/hpspells/core/util/SVPBypass.java
// public static Method getMethod(Class<?> cl, String method) {
// for (Method m : cl.getMethods()) {
// if (m.getName().equals(method)) {
// return m;
// }
// }
// return null;
// }
| import org.bukkit.inventory.ItemStack;
import java.util.Map;
import java.util.Random;
import static com.hpspells.core.util.SVPBypass.getMethod; | package com.hpspells.core.util;
/**
* A class containing a mix of effects
*/
public class MiscUtilities {
private static Class<?> cbItemStack = SVPBypass.getCurrentCBClass("inventory.CraftItemStack"), nmsItemStack = SVPBypass.getCurrentNMSClass("ItemStack"), nmsTagCompound = SVPBypass.getCurrentNMSClass("NBTTagCompound"), nmsTagList = SVPBypass.getCurrentNMSClass("NBTTagList");
/**
* Makes an {@link ItemStack} glow as if enchanted <br>
* Based on stirante's {@code addGlow} method in his <a href="https://github.com/SocialCraft/PrettyScaryLib/blob/master/src/com/stirante/PrettyScaryLib/EnchantGlow.java">EnchantGlow</a> class
*
* @param item the item stack to make glow
* @return the glowing item stack
* @throws Exception if an error occurred whilst making the item glow
*/
public static ItemStack makeGlow(ItemStack item) throws Exception { | // Path: src/com/hpspells/core/util/SVPBypass.java
// public static Method getMethod(Class<?> cl, String method) {
// for (Method m : cl.getMethods()) {
// if (m.getName().equals(method)) {
// return m;
// }
// }
// return null;
// }
// Path: src/com/hpspells/core/util/MiscUtilities.java
import org.bukkit.inventory.ItemStack;
import java.util.Map;
import java.util.Random;
import static com.hpspells.core.util.SVPBypass.getMethod;
package com.hpspells.core.util;
/**
* A class containing a mix of effects
*/
public class MiscUtilities {
private static Class<?> cbItemStack = SVPBypass.getCurrentCBClass("inventory.CraftItemStack"), nmsItemStack = SVPBypass.getCurrentNMSClass("ItemStack"), nmsTagCompound = SVPBypass.getCurrentNMSClass("NBTTagCompound"), nmsTagList = SVPBypass.getCurrentNMSClass("NBTTagList");
/**
* Makes an {@link ItemStack} glow as if enchanted <br>
* Based on stirante's {@code addGlow} method in his <a href="https://github.com/SocialCraft/PrettyScaryLib/blob/master/src/com/stirante/PrettyScaryLib/EnchantGlow.java">EnchantGlow</a> class
*
* @param item the item stack to make glow
* @return the glowing item stack
* @throws Exception if an error occurred whilst making the item glow
*/
public static ItemStack makeGlow(ItemStack item) throws Exception { | Object nmsStack = getMethod(cbItemStack, "asNMSCopy").invoke(cbItemStack, item); |
HarryPotterSpells/HarryPotterSpells | src/com/hpspells/core/PM.java | // Path: src/com/hpspells/core/spell/SpellNotification.java
// public enum SpellNotification {
// SPELL_SUCCESS,
// SPELL_FAILED,
// SPELL_MISSED;
// }
| import com.hpspells.core.spell.SpellNotification;
import org.bukkit.ChatColor;
import org.bukkit.Instrument;
import org.bukkit.Note;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import java.util.logging.Level;
import java.util.logging.Logger; | package com.hpspells.core;
/**
* PM stands for PluginMessenger. <br>
* This class manages logs and other ways of sending messages to players/console.
*/
public class PM {
private Logger log;
private HPS HPS;
private String tag;
private ChatColor info, warning;
/**
* Constructs an instance of {@link PM}
*
* @param instance an instance of {@link HPS}
*/
public PM(HPS instance) {
this.HPS = instance;
this.log = HPS.getLogger();
this.tag = ChatColor.translateAlternateColorCodes('&', HPS.getConfig().getString("messaging.tag", "&f[&6HarryPotterSpells&f] "));
this.info = ChatColor.valueOf(HPS.getConfig().getString("messaging.info", "YELLOW"));
this.warning = ChatColor.valueOf(HPS.getConfig().getString("messaging.warning", "RED"));
}
/**
* CURRENTLY A DUMMY METHOD, SOMEONE NEEDS TO ENTER VALUES FOR THIS!
*
* @param player The player to send the spell notification to
* @param spellNotification The notification you want to give the player of the spells status
* <p/>
* zachoooo: We need to get some programmer thats good at music to help decide/test what these should be.
*/ | // Path: src/com/hpspells/core/spell/SpellNotification.java
// public enum SpellNotification {
// SPELL_SUCCESS,
// SPELL_FAILED,
// SPELL_MISSED;
// }
// Path: src/com/hpspells/core/PM.java
import com.hpspells.core.spell.SpellNotification;
import org.bukkit.ChatColor;
import org.bukkit.Instrument;
import org.bukkit.Note;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import java.util.logging.Level;
import java.util.logging.Logger;
package com.hpspells.core;
/**
* PM stands for PluginMessenger. <br>
* This class manages logs and other ways of sending messages to players/console.
*/
public class PM {
private Logger log;
private HPS HPS;
private String tag;
private ChatColor info, warning;
/**
* Constructs an instance of {@link PM}
*
* @param instance an instance of {@link HPS}
*/
public PM(HPS instance) {
this.HPS = instance;
this.log = HPS.getLogger();
this.tag = ChatColor.translateAlternateColorCodes('&', HPS.getConfig().getString("messaging.tag", "&f[&6HarryPotterSpells&f] "));
this.info = ChatColor.valueOf(HPS.getConfig().getString("messaging.info", "YELLOW"));
this.warning = ChatColor.valueOf(HPS.getConfig().getString("messaging.warning", "RED"));
}
/**
* CURRENTLY A DUMMY METHOD, SOMEONE NEEDS TO ENTER VALUES FOR THIS!
*
* @param player The player to send the spell notification to
* @param spellNotification The notification you want to give the player of the spells status
* <p/>
* zachoooo: We need to get some programmer thats good at music to help decide/test what these should be.
*/ | public void sendPlayerSpellNotification(Player player, SpellNotification spellNotification) { |
HarryPotterSpells/HarryPotterSpells | src/com/hpspells/core/util/FireworkEffectPlayer.java | // Path: src/com/hpspells/core/util/SVPBypass.java
// public static Method getMethod(Class<?> cl, String method) {
// for (Method m : cl.getMethods()) {
// if (m.getName().equals(method)) {
// return m;
// }
// }
// return null;
// }
| import static com.hpspells.core.util.SVPBypass.getMethod;
import java.lang.reflect.Method;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.inventory.meta.FireworkMeta; | package com.hpspells.core.util;
/**
* FireworkEffectPlayer v1.0
* <p/>
* FireworkEffectPlayer provides a thread-safe and (reasonably) version independant way to instantly explode a FireworkEffect at a given location.
* You are welcome to use, redistribute, modify and destroy your own copies of this source with the following conditions:
* <p/>
* 1. No warranty is given or implied.
* 2. All damage is your own responsibility.
* 3. You provide credit publicly to the original source should you release the plugin.
*
* @author codename_B
*/
public class FireworkEffectPlayer {
/*
* Example use:
*
* public class FireWorkPlugin implements Listener {
*
* FireworkEffectPlayer fplayer = new FireworkEffectPlayer();
*
* @EventHandler
* public void onPlayerLogin(PlayerLoginEvent event) {
* fplayer.playFirework(event.getPlayer().getWorld(), event.getPlayer.getLocation(), Util.getRandomFireworkEffect());
* }
*
* }
*/
// internal references, performance improvements
private static Method world_getHandle = null, nms_world_broadcastEntityEffect = null, firework_getHandle = null;
/**
* Play a pretty firework at the location with the FireworkEffect when called
*
* @param world
* @param loc
* @param fe
* @throws Exception
*/
public static void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
// Bukkity load (CraftFirework)
Firework fw = (Firework) world.spawn(loc, Firework.class);
// the net.minecraft.server.World
Object nms_world = null;
Object nms_firework = null;
/*
* The reflection part, this gives us access to funky ways of messing around with things
*/
if (world_getHandle == null) {
// get the methods of the craftbukkit objects | // Path: src/com/hpspells/core/util/SVPBypass.java
// public static Method getMethod(Class<?> cl, String method) {
// for (Method m : cl.getMethods()) {
// if (m.getName().equals(method)) {
// return m;
// }
// }
// return null;
// }
// Path: src/com/hpspells/core/util/FireworkEffectPlayer.java
import static com.hpspells.core.util.SVPBypass.getMethod;
import java.lang.reflect.Method;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.inventory.meta.FireworkMeta;
package com.hpspells.core.util;
/**
* FireworkEffectPlayer v1.0
* <p/>
* FireworkEffectPlayer provides a thread-safe and (reasonably) version independant way to instantly explode a FireworkEffect at a given location.
* You are welcome to use, redistribute, modify and destroy your own copies of this source with the following conditions:
* <p/>
* 1. No warranty is given or implied.
* 2. All damage is your own responsibility.
* 3. You provide credit publicly to the original source should you release the plugin.
*
* @author codename_B
*/
public class FireworkEffectPlayer {
/*
* Example use:
*
* public class FireWorkPlugin implements Listener {
*
* FireworkEffectPlayer fplayer = new FireworkEffectPlayer();
*
* @EventHandler
* public void onPlayerLogin(PlayerLoginEvent event) {
* fplayer.playFirework(event.getPlayer().getWorld(), event.getPlayer.getLocation(), Util.getRandomFireworkEffect());
* }
*
* }
*/
// internal references, performance improvements
private static Method world_getHandle = null, nms_world_broadcastEntityEffect = null, firework_getHandle = null;
/**
* Play a pretty firework at the location with the FireworkEffect when called
*
* @param world
* @param loc
* @param fe
* @throws Exception
*/
public static void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
// Bukkity load (CraftFirework)
Firework fw = (Firework) world.spawn(loc, Firework.class);
// the net.minecraft.server.World
Object nms_world = null;
Object nms_firework = null;
/*
* The reflection part, this gives us access to funky ways of messing around with things
*/
if (world_getHandle == null) {
// get the methods of the craftbukkit objects | world_getHandle = getMethod(world.getClass(), "getHandle"); |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/account/Balance.java | // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
| import net.sf.json.JSONObject;
import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency; | package com.hoiio.sdk.objects.account;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class Balance extends HoiioResponse {
private static enum Params {
CURRENCY, BALANCE, POINTS, BONUS;
public String toString() {
return this.name().toLowerCase();
}
}
| // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
// Path: src/com/hoiio/sdk/objects/account/Balance.java
import net.sf.json.JSONObject;
import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency;
package com.hoiio.sdk.objects.account;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class Balance extends HoiioResponse {
private static enum Params {
CURRENCY, BALANCE, POINTS, BONUS;
public String toString() {
return this.name().toLowerCase();
}
}
| private Currency currency; |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/fax/FaxRate.java | // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
| import net.sf.json.JSONObject;
import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency; | package com.hoiio.sdk.objects.fax;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class FaxRate extends HoiioResponse {
private static enum Params {
CURRENCY, RATE;
public String toString() {
return this.name().toLowerCase();
}
}
| // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
// Path: src/com/hoiio/sdk/objects/fax/FaxRate.java
import net.sf.json.JSONObject;
import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency;
package com.hoiio.sdk.objects.fax;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class FaxRate extends HoiioResponse {
private static enum Params {
CURRENCY, RATE;
public String toString() {
return this.name().toLowerCase();
}
}
| private Currency currency; |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/number/ActiveNumber.java | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
| import com.hoiio.sdk.exception.HoiioException;
import com.hoiio.sdk.objects.HoiioResponse;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject; | package com.hoiio.sdk.objects.number;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class ActiveNumber extends HoiioResponse {
private static enum Params {
ENTRIES_COUNT, ENTRIES;
public String toString() {
return this.name().toLowerCase();
}
}
private int pageCount;
private List<Number> numberList;
/**
* Constructs a new {@code ActiveNumber} object by decoding the {@code JSONObject} as a response from the HTTP Request
* @param output The response of the HTTP Request
*/ | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
// Path: src/com/hoiio/sdk/objects/number/ActiveNumber.java
import com.hoiio.sdk.exception.HoiioException;
import com.hoiio.sdk.objects.HoiioResponse;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
package com.hoiio.sdk.objects.number;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class ActiveNumber extends HoiioResponse {
private static enum Params {
ENTRIES_COUNT, ENTRIES;
public String toString() {
return this.name().toLowerCase();
}
}
private int pageCount;
private List<Number> numberList;
/**
* Constructs a new {@code ActiveNumber} object by decoding the {@code JSONObject} as a response from the HTTP Request
* @param output The response of the HTTP Request
*/ | public ActiveNumber(JSONObject output) throws HoiioException { |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/sms/SmsHistory.java | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
| import com.hoiio.sdk.exception.HoiioException;
import com.hoiio.sdk.objects.HoiioResponse;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject; | package com.hoiio.sdk.objects.sms;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class SmsHistory extends HoiioResponse {
private static enum Params {
ENTRIES_COUNT, TOTAL_ENTRIES_COUNT, ENTRIES;
public String toString() {
return this.name().toLowerCase();
}
}
private int pageCount;
private int totalCount;
private List<Sms> smsList;
/**
* Constructs a new {@code SmsHistory} object by decoding the {@code JSONObject} as a response from the HTTP Request
* @param output The response of the HTTP Request
*/ | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
// Path: src/com/hoiio/sdk/objects/sms/SmsHistory.java
import com.hoiio.sdk.exception.HoiioException;
import com.hoiio.sdk.objects.HoiioResponse;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
package com.hoiio.sdk.objects.sms;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class SmsHistory extends HoiioResponse {
private static enum Params {
ENTRIES_COUNT, TOTAL_ENTRIES_COUNT, ENTRIES;
public String toString() {
return this.name().toLowerCase();
}
}
private int pageCount;
private int totalCount;
private List<Sms> smsList;
/**
* Constructs a new {@code SmsHistory} object by decoding the {@code JSONObject} as a response from the HTTP Request
* @param output The response of the HTTP Request
*/ | public SmsHistory(JSONObject output) throws HoiioException { |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/number/State.java | // Path: src/com/hoiio/sdk/objects/enums/NumberCapability.java
// public enum NumberCapability {
//
// VOICE("VOICE"),
// SMS("SMS");
//
// private static final Map<String, NumberCapability> lookup = new HashMap<String, NumberCapability>();
//
// private String capability;
//
// private NumberCapability(String status) {
// this.capability = status;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return capability;
// }
//
// static {
// for (NumberCapability s : NumberCapability.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code NumberCapability} object
// * @param status The number capability in string
// * @return {@code NumberCapability} object
// */
// public static NumberCapability fromString(String status) {
// return lookup.get(status);
// }
// }
| import com.hoiio.sdk.objects.enums.NumberCapability;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject; | package com.hoiio.sdk.objects.number;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class State {
private static enum Params {
NAME, CODE, CAPABILITY;
public String toString() {
return this.name().toLowerCase();
}
}
private String name;
private String code; | // Path: src/com/hoiio/sdk/objects/enums/NumberCapability.java
// public enum NumberCapability {
//
// VOICE("VOICE"),
// SMS("SMS");
//
// private static final Map<String, NumberCapability> lookup = new HashMap<String, NumberCapability>();
//
// private String capability;
//
// private NumberCapability(String status) {
// this.capability = status;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return capability;
// }
//
// static {
// for (NumberCapability s : NumberCapability.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code NumberCapability} object
// * @param status The number capability in string
// * @return {@code NumberCapability} object
// */
// public static NumberCapability fromString(String status) {
// return lookup.get(status);
// }
// }
// Path: src/com/hoiio/sdk/objects/number/State.java
import com.hoiio.sdk.objects.enums.NumberCapability;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
package com.hoiio.sdk.objects.number;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class State {
private static enum Params {
NAME, CODE, CAPABILITY;
public String toString() {
return this.name().toLowerCase();
}
}
private String name;
private String code; | private List<NumberCapability> capability; |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/fax/FaxHistory.java | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
| import com.hoiio.sdk.exception.HoiioException;
import com.hoiio.sdk.objects.HoiioResponse;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject; | package com.hoiio.sdk.objects.fax;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class FaxHistory extends HoiioResponse {
private static enum Params {
ENTRIES_COUNT, TOTAL_ENTRIES_COUNT, ENTRIES;
public String toString() {
return this.name().toLowerCase();
}
}
private int pageCount;
private int totalCount;
private List<Fax> faxList;
/**
* Constructs a new {@code FaxHistory} object by decoding the {@code JSONObject} as a response from the HTTP Request
* @param output The response of the HTTP Request
* @throws HoiioException
*/ | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
// Path: src/com/hoiio/sdk/objects/fax/FaxHistory.java
import com.hoiio.sdk.exception.HoiioException;
import com.hoiio.sdk.objects.HoiioResponse;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
package com.hoiio.sdk.objects.fax;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class FaxHistory extends HoiioResponse {
private static enum Params {
ENTRIES_COUNT, TOTAL_ENTRIES_COUNT, ENTRIES;
public String toString() {
return this.name().toLowerCase();
}
}
private int pageCount;
private int totalCount;
private List<Fax> faxList;
/**
* Constructs a new {@code FaxHistory} object by decoding the {@code JSONObject} as a response from the HTTP Request
* @param output The response of the HTTP Request
* @throws HoiioException
*/ | public FaxHistory(JSONObject output) throws HoiioException { |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/HoiioRequest.java | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
| import java.util.HashMap;
import com.hoiio.sdk.exception.HoiioException; | package com.hoiio.sdk.objects;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class HoiioRequest extends HashMap<String, String> {
private static final long serialVersionUID = 1L;
/**
* Constructs the {@code HoiioRequest} object
*/
public HoiioRequest() {
}
/**
* Puts the parameter into the Map. If the parameter is required, check for nullablity.
* @param key The key of the parameter
* @param value The value of the parameter
* @param isRequired The indicator of whether this parameter is required or not.
* @throws HoiioException
*/ | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
// Path: src/com/hoiio/sdk/objects/HoiioRequest.java
import java.util.HashMap;
import com.hoiio.sdk.exception.HoiioException;
package com.hoiio.sdk.objects;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class HoiioRequest extends HashMap<String, String> {
private static final long serialVersionUID = 1L;
/**
* Constructs the {@code HoiioRequest} object
*/
public HoiioRequest() {
}
/**
* Puts the parameter into the Map. If the parameter is required, check for nullablity.
* @param key The key of the parameter
* @param value The value of the parameter
* @param isRequired The indicator of whether this parameter is required or not.
* @throws HoiioException
*/ | public void put(String key, Object value, boolean isRequired) throws HoiioException { |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/account/Account.java | // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
| import net.sf.json.JSONObject;
import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency; | package com.hoiio.sdk.objects.account;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class Account extends HoiioResponse {
private static enum Params {
UID, NAME, MOBILE_NUMBER, EMAIL, COUNTRY, PREFIX, CURRENCY;
public String toString() {
return this.name().toLowerCase();
}
}
private String uid;
private String name;
private String mobileNumber;
private String email;
private String country;
private String prefix; | // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
// Path: src/com/hoiio/sdk/objects/account/Account.java
import net.sf.json.JSONObject;
import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency;
package com.hoiio.sdk.objects.account;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class Account extends HoiioResponse {
private static enum Params {
UID, NAME, MOBILE_NUMBER, EMAIL, COUNTRY, PREFIX, CURRENCY;
public String toString() {
return this.name().toLowerCase();
}
}
private String uid;
private String name;
private String mobileNumber;
private String email;
private String country;
private String prefix; | private Currency currency; |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/sms/SmsRate.java | // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
| import net.sf.json.JSONObject;
import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency; | package com.hoiio.sdk.objects.sms;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class SmsRate extends HoiioResponse {
private static enum Params {
RATE, CURRENCY, SPLIT_COUNT, TOTAL_COST, IS_UNICODE;
public String toString() {
return this.name().toLowerCase();
}
}
| // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
// Path: src/com/hoiio/sdk/objects/sms/SmsRate.java
import net.sf.json.JSONObject;
import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency;
package com.hoiio.sdk.objects.sms;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class SmsRate extends HoiioResponse {
private static enum Params {
RATE, CURRENCY, SPLIT_COUNT, TOTAL_COST, IS_UNICODE;
public String toString() {
return this.name().toLowerCase();
}
}
| private Currency currency; |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/voice/CallHistory.java | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
| import com.hoiio.sdk.exception.HoiioException;
import com.hoiio.sdk.objects.HoiioResponse;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject; | package com.hoiio.sdk.objects.voice;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class CallHistory extends HoiioResponse {
private static enum Params {
ENTRIES_COUNT, TOTAL_ENTRIES_COUNT, ENTRIES;
public String toString() {
return this.name().toLowerCase();
}
}
private int pageCount;
private int totalCount;
private List<Call> callList;
/**
* Constructs a new {@code CallHistory} object by decoding the {@code JSONObject} as a response from the HTTP Request
* @param output The response of the HTTP Request
*/ | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
// Path: src/com/hoiio/sdk/objects/voice/CallHistory.java
import com.hoiio.sdk.exception.HoiioException;
import com.hoiio.sdk.objects.HoiioResponse;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
package com.hoiio.sdk.objects.voice;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class CallHistory extends HoiioResponse {
private static enum Params {
ENTRIES_COUNT, TOTAL_ENTRIES_COUNT, ENTRIES;
public String toString() {
return this.name().toLowerCase();
}
}
private int pageCount;
private int totalCount;
private List<Call> callList;
/**
* Constructs a new {@code CallHistory} object by decoding the {@code JSONObject} as a response from the HTTP Request
* @param output The response of the HTTP Request
*/ | public CallHistory(JSONObject output) throws HoiioException { |
Hoiio/hoiio-java | src/com/hoiio/sdk/util/DateUtil.java | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
| import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.hoiio.sdk.exception.HoiioException; | package com.hoiio.sdk.util;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class DateUtil {
/**
* Converts the {@code date} to {@code String}
* @param date The {@code Date} object
* @return The date in this format "yyyy-MM-dd HH:mm:ss"
*/
public static String dateToString(Date date) {
if (date == null) {
return null;
}
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
}
/**
* Converts the @{code String} in date/time format to {@code Date}
* @param dateString The date in this format "yyyy-MM-dd HH:mm:ss"
* @return The {@code Date} object
* @throws HoiioException
*/ | // Path: src/com/hoiio/sdk/exception/HoiioException.java
// public class HoiioException extends Exception {
//
// private static final long serialVersionUID = 1L;
//
// private HoiioStatus status;
// private String response;
//
// /**
// * Constructs the HoiioException object
// */
// public HoiioException() {
// super();
// }
//
// /**
// * Constructs the HoiioException object
// * @param e The exception returned by other sources
// */
// public HoiioException(Exception e) {
// super(e);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// */
// public HoiioException(String status) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// }
//
// /**
// * Constructs the HoiioException object
// * @param status The error status returned by Hoiio
// * @param response Full response by Hoiio
// */
// public HoiioException(String status, String response) {
// super(status);
// this.status = HoiioStatus.fromString(status);
// this.response = response;
// }
//
// /**
// * Gets the Hoiio error status
// * @return Hoiio error status
// */
// public HoiioStatus getStatus() {
// return status;
// }
//
// /**
// * Gets the response content by Hoiio
// * @return The response content by Hoiio
// */
// public String getContent() {
// return response;
// }
// }
// Path: src/com/hoiio/sdk/util/DateUtil.java
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.hoiio.sdk.exception.HoiioException;
package com.hoiio.sdk.util;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class DateUtil {
/**
* Converts the {@code date} to {@code String}
* @param date The {@code Date} object
* @return The date in this format "yyyy-MM-dd HH:mm:ss"
*/
public static String dateToString(Date date) {
if (date == null) {
return null;
}
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
}
/**
* Converts the @{code String} in date/time format to {@code Date}
* @param dateString The date in this format "yyyy-MM-dd HH:mm:ss"
* @return The {@code Date} object
* @throws HoiioException
*/ | public static Date stringToDateTime(String dateString) throws HoiioException { |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/number/NumberRate.java | // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
| import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject; | package com.hoiio.sdk.objects.number;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class NumberRate extends HoiioResponse {
private static enum Params {
CURRENCY, ENTRIES_COUNT, ENTRIES;
public String toString() {
return this.name().toLowerCase();
}
}
| // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
// Path: src/com/hoiio/sdk/objects/number/NumberRate.java
import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
package com.hoiio.sdk.objects.number;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class NumberRate extends HoiioResponse {
private static enum Params {
CURRENCY, ENTRIES_COUNT, ENTRIES;
public String toString() {
return this.name().toLowerCase();
}
}
| private Currency currency; |
Hoiio/hoiio-java | src/com/hoiio/sdk/objects/voice/CallRate.java | // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
| import net.sf.json.JSONObject;
import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency; | package com.hoiio.sdk.objects.voice;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class CallRate extends HoiioResponse {
private static final String RATE = "rate";
private static final String CURRENCY = "currency";
private static final String TALK_TIME = "talktime";
| // Path: src/com/hoiio/sdk/objects/HoiioResponse.java
// public class HoiioResponse {
//
// protected String response;
//
// /**
// * Constructs the {@code HoiioResponse} object
// */
// public HoiioResponse() {
// }
//
// /**
// * Gets the content of the response
// * @return The raw content of the response
// */
// public String getContent() {
// return response;
// }
// }
//
// Path: src/com/hoiio/sdk/objects/enums/Currency.java
// public enum Currency {
//
// SGD("SGD"),
// HKD("HKD"),
// USD("USD"),
// AUD("AUD");
//
// private static final Map<String, Currency> lookup = new HashMap<String, Currency>();
//
// private String currency;
//
// private Currency(String currency) {
// this.currency = currency;
// }
//
// /**
// * Returns a string representation of the object
// * @return string representation of the object
// */
// public String toString() {
// return currency;
// }
//
// static {
// for (Currency s : Currency.values()) {
// lookup.put(s.toString(), s);
// }
// }
//
// /**
// * Converts the string to {@code Currency} object
// * @param currency The currency in string
// * @return {@code Currency} object
// */
// public static Currency fromString(String currency) {
// return lookup.get(currency);
// }
//
// }
// Path: src/com/hoiio/sdk/objects/voice/CallRate.java
import net.sf.json.JSONObject;
import com.hoiio.sdk.objects.HoiioResponse;
import com.hoiio.sdk.objects.enums.Currency;
package com.hoiio.sdk.objects.voice;
/*
Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
public class CallRate extends HoiioResponse {
private static final String RATE = "rate";
private static final String CURRENCY = "currency";
private static final String TALK_TIME = "talktime";
| private Currency currency; |
Cleveroad/LoopBar | LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/CategoriesAdapter.java | // Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/adapter/IOperationItem.java
// public interface IOperationItem {
//
// boolean isVisible();
//
// void setVisible(boolean isVisible);
// }
//
// Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/adapter/OperationItem.java
// public class OperationItem implements IOperationItem {
//
// private boolean isVisible = true;
//
// @Override
// public boolean isVisible() {
// return isVisible;
// }
//
// public void setVisible(boolean visible) {
// isVisible = visible;
// }
// }
| import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.cleveroad.loopbar.R;
import com.cleveroad.loopbar.adapter.IOperationItem;
import com.cleveroad.loopbar.adapter.OperationItem;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.HashMap;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; | package com.cleveroad.loopbar.widget;
class CategoriesAdapter extends RecyclerView.Adapter<BaseRecyclerViewHolder<IOperationItem>>
implements OnItemClickListener {
static final int VIEW_TYPE_OTHER = 0;
private static final int VIEW_TYPE_RESERVED_HIDDEN = -1;
@Orientation
private int mOrientation = Orientation.ORIENTATION_VERTICAL_LEFT;
private RecyclerView.Adapter<? extends RecyclerView.ViewHolder> mInputAdapter;
@SuppressLint("UseSparseArrays")
private HashMap<Integer, IOperationItem> mWrappedItems = new HashMap<>();
private WeakReference<OnItemClickListener> mListener;
private boolean mIsIndeterminate = true;
CategoriesAdapter(RecyclerView.Adapter<? extends RecyclerView.ViewHolder> inputAdapter) {
mInputAdapter = inputAdapter;
for (int i = 0; i < inputAdapter.getItemCount(); i++) { | // Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/adapter/IOperationItem.java
// public interface IOperationItem {
//
// boolean isVisible();
//
// void setVisible(boolean isVisible);
// }
//
// Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/adapter/OperationItem.java
// public class OperationItem implements IOperationItem {
//
// private boolean isVisible = true;
//
// @Override
// public boolean isVisible() {
// return isVisible;
// }
//
// public void setVisible(boolean visible) {
// isVisible = visible;
// }
// }
// Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/CategoriesAdapter.java
import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.cleveroad.loopbar.R;
import com.cleveroad.loopbar.adapter.IOperationItem;
import com.cleveroad.loopbar.adapter.OperationItem;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.HashMap;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
package com.cleveroad.loopbar.widget;
class CategoriesAdapter extends RecyclerView.Adapter<BaseRecyclerViewHolder<IOperationItem>>
implements OnItemClickListener {
static final int VIEW_TYPE_OTHER = 0;
private static final int VIEW_TYPE_RESERVED_HIDDEN = -1;
@Orientation
private int mOrientation = Orientation.ORIENTATION_VERTICAL_LEFT;
private RecyclerView.Adapter<? extends RecyclerView.ViewHolder> mInputAdapter;
@SuppressLint("UseSparseArrays")
private HashMap<Integer, IOperationItem> mWrappedItems = new HashMap<>();
private WeakReference<OnItemClickListener> mListener;
private boolean mIsIndeterminate = true;
CategoriesAdapter(RecyclerView.Adapter<? extends RecyclerView.ViewHolder> inputAdapter) {
mInputAdapter = inputAdapter;
for (int i = 0; i < inputAdapter.getItemCount(); i++) { | mWrappedItems.put(i, new OperationItem()); |
Cleveroad/LoopBar | LoopBar-widget/src/main/java/com/cleveroad/loopbar/model/MockedItemsFactory.java | // Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/adapter/ICategoryItem.java
// public interface ICategoryItem {
//
// /**
// * Returns image for displaying in Item
// *
// * @return Instance of {@link Drawable}
// */
// Drawable getCategoryIconDrawable();
//
// /**
// * Returns text for displaying in Item
// *
// * @return Instance of {@link String}
// */
// String getCategoryName();
// }
| import android.content.Context;
import androidx.core.content.ContextCompat;
import com.cleveroad.loopbar.R;
import com.cleveroad.loopbar.adapter.ICategoryItem;
import java.util.ArrayList;
import java.util.List; | package com.cleveroad.loopbar.model;
public class MockedItemsFactory {
private MockedItemsFactory() {}
| // Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/adapter/ICategoryItem.java
// public interface ICategoryItem {
//
// /**
// * Returns image for displaying in Item
// *
// * @return Instance of {@link Drawable}
// */
// Drawable getCategoryIconDrawable();
//
// /**
// * Returns text for displaying in Item
// *
// * @return Instance of {@link String}
// */
// String getCategoryName();
// }
// Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/model/MockedItemsFactory.java
import android.content.Context;
import androidx.core.content.ContextCompat;
import com.cleveroad.loopbar.R;
import com.cleveroad.loopbar.adapter.ICategoryItem;
import java.util.ArrayList;
import java.util.List;
package com.cleveroad.loopbar.model;
public class MockedItemsFactory {
private MockedItemsFactory() {}
| public static List<ICategoryItem> getCategoryItems(Context context) { |
Cleveroad/LoopBar | sample/src/main/java/com/cleveroad/sample/MainActivity.java | // Path: sample/src/main/java/com/cleveroad/sample/fragments/CategoriesAdapterLoopBarFragment.java
// public class CategoriesAdapterLoopBarFragment extends AbstractLoopBarFragment {
// public static CategoriesAdapterLoopBarFragment newInstance(int orientation) {
// Bundle args = new Bundle();
// args.putInt(EXTRA_ORIENTATION, orientation);
//
// CategoriesAdapterLoopBarFragment fragment = new CategoriesAdapterLoopBarFragment();
// fragment.setArguments(args);
// return fragment;
// }
//
// @Override
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// LoopBarView loopBarView = getLoopBarView();
// loopBarView.setCategoriesAdapter(new SimpleCategoriesAdapter(MockedItemsFactory.getCategoryItems(getContext())));
// }
//
// @Override
// protected Fragment getNewInstance(int orientation) {
// return newInstance(orientation);
// }
// }
| import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.cleveroad.loopbar.widget.Orientation;
import com.cleveroad.sample.fragments.CategoriesAdapterLoopBarFragment; | package com.cleveroad.sample;
public class MainActivity extends AppCompatActivity implements IFragmentReplacer {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) { | // Path: sample/src/main/java/com/cleveroad/sample/fragments/CategoriesAdapterLoopBarFragment.java
// public class CategoriesAdapterLoopBarFragment extends AbstractLoopBarFragment {
// public static CategoriesAdapterLoopBarFragment newInstance(int orientation) {
// Bundle args = new Bundle();
// args.putInt(EXTRA_ORIENTATION, orientation);
//
// CategoriesAdapterLoopBarFragment fragment = new CategoriesAdapterLoopBarFragment();
// fragment.setArguments(args);
// return fragment;
// }
//
// @Override
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// LoopBarView loopBarView = getLoopBarView();
// loopBarView.setCategoriesAdapter(new SimpleCategoriesAdapter(MockedItemsFactory.getCategoryItems(getContext())));
// }
//
// @Override
// protected Fragment getNewInstance(int orientation) {
// return newInstance(orientation);
// }
// }
// Path: sample/src/main/java/com/cleveroad/sample/MainActivity.java
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.cleveroad.loopbar.widget.Orientation;
import com.cleveroad.sample.fragments.CategoriesAdapterLoopBarFragment;
package com.cleveroad.sample;
public class MainActivity extends AppCompatActivity implements IFragmentReplacer {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) { | replaceFragment(CategoriesAdapterLoopBarFragment.newInstance(Orientation.ORIENTATION_VERTICAL_LEFT)); |
Cleveroad/LoopBar | LoopBar-widget/src/main/java/com/cleveroad/loopbar/adapter/BaseRecyclerViewHolder.java | // Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/OnItemClickListener.java
// public interface OnItemClickListener {
//
// /**
// * Must be called when user clicks on item in LoopBar
// *
// * @param position int value of item position in LoopBar
// */
// void onItemClicked(int position);
// }
| import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.cleveroad.loopbar.widget.OnItemClickListener;
import java.lang.ref.WeakReference; | package com.cleveroad.loopbar.adapter;
/**
* Base realization of ViewHolder {@link androidx.recyclerview.widget.RecyclerView.ViewHolder}
*
* @param <T> Type of models for displaying in ViewHolder
*/
@SuppressWarnings("WeakerAccess")
public abstract class BaseRecyclerViewHolder<T> extends RecyclerView.ViewHolder implements View.OnClickListener {
protected static final int KEY_VIEW_TAG = -1;
private static final String TAG_ITEM_VIEW = "itemView";
private T item;
@Nullable | // Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/widget/OnItemClickListener.java
// public interface OnItemClickListener {
//
// /**
// * Must be called when user clicks on item in LoopBar
// *
// * @param position int value of item position in LoopBar
// */
// void onItemClicked(int position);
// }
// Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/adapter/BaseRecyclerViewHolder.java
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.cleveroad.loopbar.widget.OnItemClickListener;
import java.lang.ref.WeakReference;
package com.cleveroad.loopbar.adapter;
/**
* Base realization of ViewHolder {@link androidx.recyclerview.widget.RecyclerView.ViewHolder}
*
* @param <T> Type of models for displaying in ViewHolder
*/
@SuppressWarnings("WeakerAccess")
public abstract class BaseRecyclerViewHolder<T> extends RecyclerView.ViewHolder implements View.OnClickListener {
protected static final int KEY_VIEW_TAG = -1;
private static final String TAG_ITEM_VIEW = "itemView";
private T item;
@Nullable | private WeakReference<OnItemClickListener> mWeakRefListener; |
Cleveroad/LoopBar | LoopBar-widget/src/main/java/com/cleveroad/loopbar/adapter/SimpleCategoriesMenuAdapter.java | // Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/model/CategoryItem.java
// public class CategoryItem implements ICategoryItem {
//
// private Drawable mCategoryDrawable;
// private String mCategoryName;
//
// public CategoryItem(Drawable drawable, String categoryName) {
// mCategoryDrawable = drawable;
// mCategoryName = categoryName;
// }
//
// @Override
// public Drawable getCategoryIconDrawable() {
// return mCategoryDrawable;
// }
//
// @Override
// public String getCategoryName() {
// return mCategoryName;
// }
//
// @Override
// public String toString() {
// return mCategoryName;
// }
//
// @Override
// public int hashCode() {
// return mCategoryName.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// return o instanceof CategoryItem && ((CategoryItem) o).mCategoryName.equals(mCategoryName);
// }
// }
| import android.view.Menu;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import com.cleveroad.loopbar.model.CategoryItem;
import java.util.ArrayList;
import java.util.List; | package com.cleveroad.loopbar.adapter;
public class SimpleCategoriesMenuAdapter extends SimpleCategoriesAdapter {
public SimpleCategoriesMenuAdapter(@NonNull Menu menu) {
super(convertMenuToCategoriesList(menu));
}
@NonNull
private static List<ICategoryItem> convertMenuToCategoriesList(@NonNull Menu menu) {
List<ICategoryItem> result = new ArrayList<>(menu.size());
for (int i = 0, size = menu.size(); i < size; i++) {
MenuItem menuItem = menu.getItem(i); | // Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/model/CategoryItem.java
// public class CategoryItem implements ICategoryItem {
//
// private Drawable mCategoryDrawable;
// private String mCategoryName;
//
// public CategoryItem(Drawable drawable, String categoryName) {
// mCategoryDrawable = drawable;
// mCategoryName = categoryName;
// }
//
// @Override
// public Drawable getCategoryIconDrawable() {
// return mCategoryDrawable;
// }
//
// @Override
// public String getCategoryName() {
// return mCategoryName;
// }
//
// @Override
// public String toString() {
// return mCategoryName;
// }
//
// @Override
// public int hashCode() {
// return mCategoryName.hashCode();
// }
//
// @Override
// public boolean equals(Object o) {
// return o instanceof CategoryItem && ((CategoryItem) o).mCategoryName.equals(mCategoryName);
// }
// }
// Path: LoopBar-widget/src/main/java/com/cleveroad/loopbar/adapter/SimpleCategoriesMenuAdapter.java
import android.view.Menu;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import com.cleveroad.loopbar.model.CategoryItem;
import java.util.ArrayList;
import java.util.List;
package com.cleveroad.loopbar.adapter;
public class SimpleCategoriesMenuAdapter extends SimpleCategoriesAdapter {
public SimpleCategoriesMenuAdapter(@NonNull Menu menu) {
super(convertMenuToCategoriesList(menu));
}
@NonNull
private static List<ICategoryItem> convertMenuToCategoriesList(@NonNull Menu menu) {
List<ICategoryItem> result = new ArrayList<>(menu.size());
for (int i = 0, size = menu.size(); i < size; i++) {
MenuItem menuItem = menu.getItem(i); | result.add(new CategoryItem(menuItem.getIcon(), String.valueOf(menuItem.getTitle()))); |
joeattardi/tailstreamer | src/main/java/com/thinksincode/tailstreamer/controller/MainController.java | // Path: src/main/java/com/thinksincode/tailstreamer/FileTailService.java
// @Service("fileTailService")
// public class FileTailService {
// private Logger logger = LoggerFactory.getLogger(FileTailService.class);
//
// @Autowired
// private FileWatcherService watcher;
//
// @Autowired
// private FileContentReader reader;
//
// private Path file;
//
// /**
// * Sets the file that will be tailed.
// * @param filePath The path of the file to tail.
// */
// public void setFile(final String filePath) {
// file = Paths.get(filePath).toAbsolutePath();
// }
//
// /**
// * Gets the path of the file being tailed.
// * @return the absolute path of the file
// */
// public String getFilePath() {
// return file.toString();
// }
//
// /**
// * Gets the name of the file being tailed.
// * @return the file name only
// */
// public String getFileName() {
// return file.getFileName().toString();
// }
//
// /**
// * Begins the file tail operation on a file.
// */
// @Async
// public void tailFile() {
// logger.info("Tailing " + file);
// reader.openFile(file);
// watcher.watchFile(file);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/TailStreamer.java
// @Configuration
// @EnableAsync
// @EnableAutoConfiguration
// @ComponentScan
// public class TailStreamer implements CommandLineRunner {
// public static final String VERSION = "1.0";
//
// @Autowired
// private FileTailService fileTailService;
//
// @Value("${nonOptionArgs}")
// private String nonOptionArgs;
//
// @Override
// public void run(String...args) {
// String[] nonOptionArgsArr = nonOptionArgs.split(",");
// fileTailService.setFile(nonOptionArgsArr[0]);
// fileTailService.tailFile();
// }
//
// public static void main(String...args) {
// System.setProperty("spring.config.name", "tailstreamer");
// System.setProperty("spring.config.location", "../conf/");
//
// ArgumentProcessor argumentProcessor = new ArgumentProcessor();
// if (argumentProcessor.parseArguments(args) && argumentProcessor.validateArguments()) {
// OptionSet options = argumentProcessor.getOptions();
// if (options.has("h")) {
// System.out.println(getHelpText());
// } else if (options.has("v")) {
// System.out.println("TailStreamer version " + VERSION);
// } else if (options.has("encryptPassword")) {
// BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
// System.out.println(encoder.encode((String) options.nonOptionArguments().get(0)));
// } else {
// TailStreamerApplication app = new TailStreamerApplication(TailStreamer.class, argumentProcessor.getOptions());
// app.run(args);
// }
// } else {
// System.err.println(argumentProcessor.getValidationErrorMessage());
// System.out.println(getHelpText());
// System.exit(1);
// }
// }
//
// public static String getHelpText() {
// return new StringBuilder()
// .append("Usage: tailstreamer [options] file\n")
// .append(" -h Print this message\n")
// .append(" -v Display version information\n")
// .append(" --encryptPassword <password> Encrypts a specified password\n")
// .append(" --server.port=PORT Listen on PORT (default 8080)\n")
// .toString();
// }
// }
| import com.thinksincode.tailstreamer.FileTailService;
import com.thinksincode.tailstreamer.TailStreamer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping; | package com.thinksincode.tailstreamer.controller;
@Controller
public class MainController {
/** The maximum filename length before truncation occurs. */
private static final int MAX_FILENAME_LENGTH = 50;
@Autowired | // Path: src/main/java/com/thinksincode/tailstreamer/FileTailService.java
// @Service("fileTailService")
// public class FileTailService {
// private Logger logger = LoggerFactory.getLogger(FileTailService.class);
//
// @Autowired
// private FileWatcherService watcher;
//
// @Autowired
// private FileContentReader reader;
//
// private Path file;
//
// /**
// * Sets the file that will be tailed.
// * @param filePath The path of the file to tail.
// */
// public void setFile(final String filePath) {
// file = Paths.get(filePath).toAbsolutePath();
// }
//
// /**
// * Gets the path of the file being tailed.
// * @return the absolute path of the file
// */
// public String getFilePath() {
// return file.toString();
// }
//
// /**
// * Gets the name of the file being tailed.
// * @return the file name only
// */
// public String getFileName() {
// return file.getFileName().toString();
// }
//
// /**
// * Begins the file tail operation on a file.
// */
// @Async
// public void tailFile() {
// logger.info("Tailing " + file);
// reader.openFile(file);
// watcher.watchFile(file);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/TailStreamer.java
// @Configuration
// @EnableAsync
// @EnableAutoConfiguration
// @ComponentScan
// public class TailStreamer implements CommandLineRunner {
// public static final String VERSION = "1.0";
//
// @Autowired
// private FileTailService fileTailService;
//
// @Value("${nonOptionArgs}")
// private String nonOptionArgs;
//
// @Override
// public void run(String...args) {
// String[] nonOptionArgsArr = nonOptionArgs.split(",");
// fileTailService.setFile(nonOptionArgsArr[0]);
// fileTailService.tailFile();
// }
//
// public static void main(String...args) {
// System.setProperty("spring.config.name", "tailstreamer");
// System.setProperty("spring.config.location", "../conf/");
//
// ArgumentProcessor argumentProcessor = new ArgumentProcessor();
// if (argumentProcessor.parseArguments(args) && argumentProcessor.validateArguments()) {
// OptionSet options = argumentProcessor.getOptions();
// if (options.has("h")) {
// System.out.println(getHelpText());
// } else if (options.has("v")) {
// System.out.println("TailStreamer version " + VERSION);
// } else if (options.has("encryptPassword")) {
// BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
// System.out.println(encoder.encode((String) options.nonOptionArguments().get(0)));
// } else {
// TailStreamerApplication app = new TailStreamerApplication(TailStreamer.class, argumentProcessor.getOptions());
// app.run(args);
// }
// } else {
// System.err.println(argumentProcessor.getValidationErrorMessage());
// System.out.println(getHelpText());
// System.exit(1);
// }
// }
//
// public static String getHelpText() {
// return new StringBuilder()
// .append("Usage: tailstreamer [options] file\n")
// .append(" -h Print this message\n")
// .append(" -v Display version information\n")
// .append(" --encryptPassword <password> Encrypts a specified password\n")
// .append(" --server.port=PORT Listen on PORT (default 8080)\n")
// .toString();
// }
// }
// Path: src/main/java/com/thinksincode/tailstreamer/controller/MainController.java
import com.thinksincode.tailstreamer.FileTailService;
import com.thinksincode.tailstreamer.TailStreamer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
package com.thinksincode.tailstreamer.controller;
@Controller
public class MainController {
/** The maximum filename length before truncation occurs. */
private static final int MAX_FILENAME_LENGTH = 50;
@Autowired | private FileTailService fileTailService; |
joeattardi/tailstreamer | src/main/java/com/thinksincode/tailstreamer/controller/MainController.java | // Path: src/main/java/com/thinksincode/tailstreamer/FileTailService.java
// @Service("fileTailService")
// public class FileTailService {
// private Logger logger = LoggerFactory.getLogger(FileTailService.class);
//
// @Autowired
// private FileWatcherService watcher;
//
// @Autowired
// private FileContentReader reader;
//
// private Path file;
//
// /**
// * Sets the file that will be tailed.
// * @param filePath The path of the file to tail.
// */
// public void setFile(final String filePath) {
// file = Paths.get(filePath).toAbsolutePath();
// }
//
// /**
// * Gets the path of the file being tailed.
// * @return the absolute path of the file
// */
// public String getFilePath() {
// return file.toString();
// }
//
// /**
// * Gets the name of the file being tailed.
// * @return the file name only
// */
// public String getFileName() {
// return file.getFileName().toString();
// }
//
// /**
// * Begins the file tail operation on a file.
// */
// @Async
// public void tailFile() {
// logger.info("Tailing " + file);
// reader.openFile(file);
// watcher.watchFile(file);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/TailStreamer.java
// @Configuration
// @EnableAsync
// @EnableAutoConfiguration
// @ComponentScan
// public class TailStreamer implements CommandLineRunner {
// public static final String VERSION = "1.0";
//
// @Autowired
// private FileTailService fileTailService;
//
// @Value("${nonOptionArgs}")
// private String nonOptionArgs;
//
// @Override
// public void run(String...args) {
// String[] nonOptionArgsArr = nonOptionArgs.split(",");
// fileTailService.setFile(nonOptionArgsArr[0]);
// fileTailService.tailFile();
// }
//
// public static void main(String...args) {
// System.setProperty("spring.config.name", "tailstreamer");
// System.setProperty("spring.config.location", "../conf/");
//
// ArgumentProcessor argumentProcessor = new ArgumentProcessor();
// if (argumentProcessor.parseArguments(args) && argumentProcessor.validateArguments()) {
// OptionSet options = argumentProcessor.getOptions();
// if (options.has("h")) {
// System.out.println(getHelpText());
// } else if (options.has("v")) {
// System.out.println("TailStreamer version " + VERSION);
// } else if (options.has("encryptPassword")) {
// BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
// System.out.println(encoder.encode((String) options.nonOptionArguments().get(0)));
// } else {
// TailStreamerApplication app = new TailStreamerApplication(TailStreamer.class, argumentProcessor.getOptions());
// app.run(args);
// }
// } else {
// System.err.println(argumentProcessor.getValidationErrorMessage());
// System.out.println(getHelpText());
// System.exit(1);
// }
// }
//
// public static String getHelpText() {
// return new StringBuilder()
// .append("Usage: tailstreamer [options] file\n")
// .append(" -h Print this message\n")
// .append(" -v Display version information\n")
// .append(" --encryptPassword <password> Encrypts a specified password\n")
// .append(" --server.port=PORT Listen on PORT (default 8080)\n")
// .toString();
// }
// }
| import com.thinksincode.tailstreamer.FileTailService;
import com.thinksincode.tailstreamer.TailStreamer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping; | package com.thinksincode.tailstreamer.controller;
@Controller
public class MainController {
/** The maximum filename length before truncation occurs. */
private static final int MAX_FILENAME_LENGTH = 50;
@Autowired
private FileTailService fileTailService;
@RequestMapping("/")
public String index(Model model) {
model.addAttribute("file", maybeTruncate(fileTailService.getFileName()));
model.addAttribute("filePath", fileTailService.getFilePath()); | // Path: src/main/java/com/thinksincode/tailstreamer/FileTailService.java
// @Service("fileTailService")
// public class FileTailService {
// private Logger logger = LoggerFactory.getLogger(FileTailService.class);
//
// @Autowired
// private FileWatcherService watcher;
//
// @Autowired
// private FileContentReader reader;
//
// private Path file;
//
// /**
// * Sets the file that will be tailed.
// * @param filePath The path of the file to tail.
// */
// public void setFile(final String filePath) {
// file = Paths.get(filePath).toAbsolutePath();
// }
//
// /**
// * Gets the path of the file being tailed.
// * @return the absolute path of the file
// */
// public String getFilePath() {
// return file.toString();
// }
//
// /**
// * Gets the name of the file being tailed.
// * @return the file name only
// */
// public String getFileName() {
// return file.getFileName().toString();
// }
//
// /**
// * Begins the file tail operation on a file.
// */
// @Async
// public void tailFile() {
// logger.info("Tailing " + file);
// reader.openFile(file);
// watcher.watchFile(file);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/TailStreamer.java
// @Configuration
// @EnableAsync
// @EnableAutoConfiguration
// @ComponentScan
// public class TailStreamer implements CommandLineRunner {
// public static final String VERSION = "1.0";
//
// @Autowired
// private FileTailService fileTailService;
//
// @Value("${nonOptionArgs}")
// private String nonOptionArgs;
//
// @Override
// public void run(String...args) {
// String[] nonOptionArgsArr = nonOptionArgs.split(",");
// fileTailService.setFile(nonOptionArgsArr[0]);
// fileTailService.tailFile();
// }
//
// public static void main(String...args) {
// System.setProperty("spring.config.name", "tailstreamer");
// System.setProperty("spring.config.location", "../conf/");
//
// ArgumentProcessor argumentProcessor = new ArgumentProcessor();
// if (argumentProcessor.parseArguments(args) && argumentProcessor.validateArguments()) {
// OptionSet options = argumentProcessor.getOptions();
// if (options.has("h")) {
// System.out.println(getHelpText());
// } else if (options.has("v")) {
// System.out.println("TailStreamer version " + VERSION);
// } else if (options.has("encryptPassword")) {
// BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
// System.out.println(encoder.encode((String) options.nonOptionArguments().get(0)));
// } else {
// TailStreamerApplication app = new TailStreamerApplication(TailStreamer.class, argumentProcessor.getOptions());
// app.run(args);
// }
// } else {
// System.err.println(argumentProcessor.getValidationErrorMessage());
// System.out.println(getHelpText());
// System.exit(1);
// }
// }
//
// public static String getHelpText() {
// return new StringBuilder()
// .append("Usage: tailstreamer [options] file\n")
// .append(" -h Print this message\n")
// .append(" -v Display version information\n")
// .append(" --encryptPassword <password> Encrypts a specified password\n")
// .append(" --server.port=PORT Listen on PORT (default 8080)\n")
// .toString();
// }
// }
// Path: src/main/java/com/thinksincode/tailstreamer/controller/MainController.java
import com.thinksincode.tailstreamer.FileTailService;
import com.thinksincode.tailstreamer.TailStreamer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
package com.thinksincode.tailstreamer.controller;
@Controller
public class MainController {
/** The maximum filename length before truncation occurs. */
private static final int MAX_FILENAME_LENGTH = 50;
@Autowired
private FileTailService fileTailService;
@RequestMapping("/")
public String index(Model model) {
model.addAttribute("file", maybeTruncate(fileTailService.getFileName()));
model.addAttribute("filePath", fileTailService.getFilePath()); | model.addAttribute("version", TailStreamer.VERSION); |
joeattardi/tailstreamer | src/test/java/com/thinksincode/tailstreamer/WatchServiceFileWatcherTests.java | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/WatchServiceFileWatcher.java
// public class WatchServiceFileWatcher extends AbstractFileWatcher implements FileWatcher {
// private Logger logger = LoggerFactory.getLogger(WatchServiceFileWatcher.class);
//
// /** Flag that indicates whether the watch service should continue. */
// private boolean watch = true;
//
// /**
// * Starts watching a file.
// */
// public void watchFile(final java.nio.file.Path watchedFile) {
// try {
// WatchService watchService = FileSystems.getDefault().newWatchService();
// // WatchService only watches directories, so watch the file's parent
// Path parent = Paths.get(watchedFile.getParent().toFile().getAbsolutePath());
// parent.register(watchService, StandardWatchEventKind.ENTRY_MODIFY);
//
// // Wait for changes
// for (boolean valid = true; watch && valid; ) {
// WatchKey key = watchService.take();
// List<WatchEvent<?>> events = key.pollEvents();
// for (WatchEvent<?> event : events) {
// // overflow events can happen, we don't care about them
// if (event.kind() == StandardWatchEventKind.OVERFLOW) {
// continue;
// }
//
// // Events will fire for any files in the directory. Only
// // respond to changes to the file being watched
// Path changedFile = (Path) event.context();
// if (changedFile.toString().equals(watchedFile.getFileName().toString())) {
// notifyListeners(new FileUpdateEvent(this));
// }
// }
//
// valid = key.reset();
// }
// } catch (IOException | ClosedWatchServiceException e) {
// logger.error("Error while watching file: " + e.getMessage(), e);
// } catch (InterruptedException ie) {
// logger.warn("Watch service was interrupted", ie);
// }
// }
//
// /**
// * Signals the watcher to stop watching.
// */
// public void stop() {
// watch = false;
// }
// }
| import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.WatchServiceFileWatcher;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder; | package com.thinksincode.tailstreamer;
public class WatchServiceFileWatcherTests {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void testWatchFile() throws IOException, InterruptedException {
File file = folder.newFile();
FileWatcherThread thread = new FileWatcherThread(file);
thread.start();
Thread.sleep(1000);
FileWriter writer = new FileWriter(file);
writer.write("Hello world!\n");
writer.close();
thread.join();
Assert.assertTrue(thread.updated());
}
class FileWatcherThread extends Thread {
private File file;
private boolean updated;
public FileWatcherThread(final File file) {
this.file = file;
}
public void run() { | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/WatchServiceFileWatcher.java
// public class WatchServiceFileWatcher extends AbstractFileWatcher implements FileWatcher {
// private Logger logger = LoggerFactory.getLogger(WatchServiceFileWatcher.class);
//
// /** Flag that indicates whether the watch service should continue. */
// private boolean watch = true;
//
// /**
// * Starts watching a file.
// */
// public void watchFile(final java.nio.file.Path watchedFile) {
// try {
// WatchService watchService = FileSystems.getDefault().newWatchService();
// // WatchService only watches directories, so watch the file's parent
// Path parent = Paths.get(watchedFile.getParent().toFile().getAbsolutePath());
// parent.register(watchService, StandardWatchEventKind.ENTRY_MODIFY);
//
// // Wait for changes
// for (boolean valid = true; watch && valid; ) {
// WatchKey key = watchService.take();
// List<WatchEvent<?>> events = key.pollEvents();
// for (WatchEvent<?> event : events) {
// // overflow events can happen, we don't care about them
// if (event.kind() == StandardWatchEventKind.OVERFLOW) {
// continue;
// }
//
// // Events will fire for any files in the directory. Only
// // respond to changes to the file being watched
// Path changedFile = (Path) event.context();
// if (changedFile.toString().equals(watchedFile.getFileName().toString())) {
// notifyListeners(new FileUpdateEvent(this));
// }
// }
//
// valid = key.reset();
// }
// } catch (IOException | ClosedWatchServiceException e) {
// logger.error("Error while watching file: " + e.getMessage(), e);
// } catch (InterruptedException ie) {
// logger.warn("Watch service was interrupted", ie);
// }
// }
//
// /**
// * Signals the watcher to stop watching.
// */
// public void stop() {
// watch = false;
// }
// }
// Path: src/test/java/com/thinksincode/tailstreamer/WatchServiceFileWatcherTests.java
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.WatchServiceFileWatcher;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
package com.thinksincode.tailstreamer;
public class WatchServiceFileWatcherTests {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void testWatchFile() throws IOException, InterruptedException {
File file = folder.newFile();
FileWatcherThread thread = new FileWatcherThread(file);
thread.start();
Thread.sleep(1000);
FileWriter writer = new FileWriter(file);
writer.write("Hello world!\n");
writer.close();
thread.join();
Assert.assertTrue(thread.updated());
}
class FileWatcherThread extends Thread {
private File file;
private boolean updated;
public FileWatcherThread(final File file) {
this.file = file;
}
public void run() { | final WatchServiceFileWatcher watcher = new WatchServiceFileWatcher(); |
joeattardi/tailstreamer | src/test/java/com/thinksincode/tailstreamer/WatchServiceFileWatcherTests.java | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/WatchServiceFileWatcher.java
// public class WatchServiceFileWatcher extends AbstractFileWatcher implements FileWatcher {
// private Logger logger = LoggerFactory.getLogger(WatchServiceFileWatcher.class);
//
// /** Flag that indicates whether the watch service should continue. */
// private boolean watch = true;
//
// /**
// * Starts watching a file.
// */
// public void watchFile(final java.nio.file.Path watchedFile) {
// try {
// WatchService watchService = FileSystems.getDefault().newWatchService();
// // WatchService only watches directories, so watch the file's parent
// Path parent = Paths.get(watchedFile.getParent().toFile().getAbsolutePath());
// parent.register(watchService, StandardWatchEventKind.ENTRY_MODIFY);
//
// // Wait for changes
// for (boolean valid = true; watch && valid; ) {
// WatchKey key = watchService.take();
// List<WatchEvent<?>> events = key.pollEvents();
// for (WatchEvent<?> event : events) {
// // overflow events can happen, we don't care about them
// if (event.kind() == StandardWatchEventKind.OVERFLOW) {
// continue;
// }
//
// // Events will fire for any files in the directory. Only
// // respond to changes to the file being watched
// Path changedFile = (Path) event.context();
// if (changedFile.toString().equals(watchedFile.getFileName().toString())) {
// notifyListeners(new FileUpdateEvent(this));
// }
// }
//
// valid = key.reset();
// }
// } catch (IOException | ClosedWatchServiceException e) {
// logger.error("Error while watching file: " + e.getMessage(), e);
// } catch (InterruptedException ie) {
// logger.warn("Watch service was interrupted", ie);
// }
// }
//
// /**
// * Signals the watcher to stop watching.
// */
// public void stop() {
// watch = false;
// }
// }
| import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.WatchServiceFileWatcher;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder; | package com.thinksincode.tailstreamer;
public class WatchServiceFileWatcherTests {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void testWatchFile() throws IOException, InterruptedException {
File file = folder.newFile();
FileWatcherThread thread = new FileWatcherThread(file);
thread.start();
Thread.sleep(1000);
FileWriter writer = new FileWriter(file);
writer.write("Hello world!\n");
writer.close();
thread.join();
Assert.assertTrue(thread.updated());
}
class FileWatcherThread extends Thread {
private File file;
private boolean updated;
public FileWatcherThread(final File file) {
this.file = file;
}
public void run() {
final WatchServiceFileWatcher watcher = new WatchServiceFileWatcher(); | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/WatchServiceFileWatcher.java
// public class WatchServiceFileWatcher extends AbstractFileWatcher implements FileWatcher {
// private Logger logger = LoggerFactory.getLogger(WatchServiceFileWatcher.class);
//
// /** Flag that indicates whether the watch service should continue. */
// private boolean watch = true;
//
// /**
// * Starts watching a file.
// */
// public void watchFile(final java.nio.file.Path watchedFile) {
// try {
// WatchService watchService = FileSystems.getDefault().newWatchService();
// // WatchService only watches directories, so watch the file's parent
// Path parent = Paths.get(watchedFile.getParent().toFile().getAbsolutePath());
// parent.register(watchService, StandardWatchEventKind.ENTRY_MODIFY);
//
// // Wait for changes
// for (boolean valid = true; watch && valid; ) {
// WatchKey key = watchService.take();
// List<WatchEvent<?>> events = key.pollEvents();
// for (WatchEvent<?> event : events) {
// // overflow events can happen, we don't care about them
// if (event.kind() == StandardWatchEventKind.OVERFLOW) {
// continue;
// }
//
// // Events will fire for any files in the directory. Only
// // respond to changes to the file being watched
// Path changedFile = (Path) event.context();
// if (changedFile.toString().equals(watchedFile.getFileName().toString())) {
// notifyListeners(new FileUpdateEvent(this));
// }
// }
//
// valid = key.reset();
// }
// } catch (IOException | ClosedWatchServiceException e) {
// logger.error("Error while watching file: " + e.getMessage(), e);
// } catch (InterruptedException ie) {
// logger.warn("Watch service was interrupted", ie);
// }
// }
//
// /**
// * Signals the watcher to stop watching.
// */
// public void stop() {
// watch = false;
// }
// }
// Path: src/test/java/com/thinksincode/tailstreamer/WatchServiceFileWatcherTests.java
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.WatchServiceFileWatcher;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
package com.thinksincode.tailstreamer;
public class WatchServiceFileWatcherTests {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void testWatchFile() throws IOException, InterruptedException {
File file = folder.newFile();
FileWatcherThread thread = new FileWatcherThread(file);
thread.start();
Thread.sleep(1000);
FileWriter writer = new FileWriter(file);
writer.write("Hello world!\n");
writer.close();
thread.join();
Assert.assertTrue(thread.updated());
}
class FileWatcherThread extends Thread {
private File file;
private boolean updated;
public FileWatcherThread(final File file) {
this.file = file;
}
public void run() {
final WatchServiceFileWatcher watcher = new WatchServiceFileWatcher(); | watcher.addFileListener(new FileListener() { |
joeattardi/tailstreamer | src/test/java/com/thinksincode/tailstreamer/WatchServiceFileWatcherTests.java | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/WatchServiceFileWatcher.java
// public class WatchServiceFileWatcher extends AbstractFileWatcher implements FileWatcher {
// private Logger logger = LoggerFactory.getLogger(WatchServiceFileWatcher.class);
//
// /** Flag that indicates whether the watch service should continue. */
// private boolean watch = true;
//
// /**
// * Starts watching a file.
// */
// public void watchFile(final java.nio.file.Path watchedFile) {
// try {
// WatchService watchService = FileSystems.getDefault().newWatchService();
// // WatchService only watches directories, so watch the file's parent
// Path parent = Paths.get(watchedFile.getParent().toFile().getAbsolutePath());
// parent.register(watchService, StandardWatchEventKind.ENTRY_MODIFY);
//
// // Wait for changes
// for (boolean valid = true; watch && valid; ) {
// WatchKey key = watchService.take();
// List<WatchEvent<?>> events = key.pollEvents();
// for (WatchEvent<?> event : events) {
// // overflow events can happen, we don't care about them
// if (event.kind() == StandardWatchEventKind.OVERFLOW) {
// continue;
// }
//
// // Events will fire for any files in the directory. Only
// // respond to changes to the file being watched
// Path changedFile = (Path) event.context();
// if (changedFile.toString().equals(watchedFile.getFileName().toString())) {
// notifyListeners(new FileUpdateEvent(this));
// }
// }
//
// valid = key.reset();
// }
// } catch (IOException | ClosedWatchServiceException e) {
// logger.error("Error while watching file: " + e.getMessage(), e);
// } catch (InterruptedException ie) {
// logger.warn("Watch service was interrupted", ie);
// }
// }
//
// /**
// * Signals the watcher to stop watching.
// */
// public void stop() {
// watch = false;
// }
// }
| import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.WatchServiceFileWatcher;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder; | package com.thinksincode.tailstreamer;
public class WatchServiceFileWatcherTests {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void testWatchFile() throws IOException, InterruptedException {
File file = folder.newFile();
FileWatcherThread thread = new FileWatcherThread(file);
thread.start();
Thread.sleep(1000);
FileWriter writer = new FileWriter(file);
writer.write("Hello world!\n");
writer.close();
thread.join();
Assert.assertTrue(thread.updated());
}
class FileWatcherThread extends Thread {
private File file;
private boolean updated;
public FileWatcherThread(final File file) {
this.file = file;
}
public void run() {
final WatchServiceFileWatcher watcher = new WatchServiceFileWatcher();
watcher.addFileListener(new FileListener() {
@Override | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/WatchServiceFileWatcher.java
// public class WatchServiceFileWatcher extends AbstractFileWatcher implements FileWatcher {
// private Logger logger = LoggerFactory.getLogger(WatchServiceFileWatcher.class);
//
// /** Flag that indicates whether the watch service should continue. */
// private boolean watch = true;
//
// /**
// * Starts watching a file.
// */
// public void watchFile(final java.nio.file.Path watchedFile) {
// try {
// WatchService watchService = FileSystems.getDefault().newWatchService();
// // WatchService only watches directories, so watch the file's parent
// Path parent = Paths.get(watchedFile.getParent().toFile().getAbsolutePath());
// parent.register(watchService, StandardWatchEventKind.ENTRY_MODIFY);
//
// // Wait for changes
// for (boolean valid = true; watch && valid; ) {
// WatchKey key = watchService.take();
// List<WatchEvent<?>> events = key.pollEvents();
// for (WatchEvent<?> event : events) {
// // overflow events can happen, we don't care about them
// if (event.kind() == StandardWatchEventKind.OVERFLOW) {
// continue;
// }
//
// // Events will fire for any files in the directory. Only
// // respond to changes to the file being watched
// Path changedFile = (Path) event.context();
// if (changedFile.toString().equals(watchedFile.getFileName().toString())) {
// notifyListeners(new FileUpdateEvent(this));
// }
// }
//
// valid = key.reset();
// }
// } catch (IOException | ClosedWatchServiceException e) {
// logger.error("Error while watching file: " + e.getMessage(), e);
// } catch (InterruptedException ie) {
// logger.warn("Watch service was interrupted", ie);
// }
// }
//
// /**
// * Signals the watcher to stop watching.
// */
// public void stop() {
// watch = false;
// }
// }
// Path: src/test/java/com/thinksincode/tailstreamer/WatchServiceFileWatcherTests.java
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.WatchServiceFileWatcher;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
package com.thinksincode.tailstreamer;
public class WatchServiceFileWatcherTests {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void testWatchFile() throws IOException, InterruptedException {
File file = folder.newFile();
FileWatcherThread thread = new FileWatcherThread(file);
thread.start();
Thread.sleep(1000);
FileWriter writer = new FileWriter(file);
writer.write("Hello world!\n");
writer.close();
thread.join();
Assert.assertTrue(thread.updated());
}
class FileWatcherThread extends Thread {
private File file;
private boolean updated;
public FileWatcherThread(final File file) {
this.file = file;
}
public void run() {
final WatchServiceFileWatcher watcher = new WatchServiceFileWatcher();
watcher.addFileListener(new FileListener() {
@Override | public void fileChanged(FileUpdateEvent event) { |
joeattardi/tailstreamer | src/main/java/com/thinksincode/tailstreamer/FileWatcherService.java | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcher.java
// public interface FileWatcher {
// public void watchFile(Path file);
// public void removeFileListener(FileListener listener);
// public void addFileListener(FileListener listener);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcherFactory.java
// public class FileWatcherFactory {
// public static FileWatcher getFileWatcher() {
// return new WatchServiceFileWatcher();
// }
// }
| import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.FileWatcher;
import com.thinksincode.tailstreamer.watch.FileWatcherFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import java.nio.file.Path; | package com.thinksincode.tailstreamer;
/**
* Watches a file for changes, and notifies observers when the file is updated.
*/
@Service("fileWatcher")
public class FileWatcherService implements ApplicationEventPublisherAware, FileListener {
private Logger logger = LoggerFactory.getLogger(FileWatcherService.class);
private ApplicationEventPublisher eventPublisher;
/** Flag that indicates whether the watch service should continue. */
private boolean watch = true;
/**
* Starts watching a file.
*/
public void watchFile(final Path watchedFile) { | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcher.java
// public interface FileWatcher {
// public void watchFile(Path file);
// public void removeFileListener(FileListener listener);
// public void addFileListener(FileListener listener);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcherFactory.java
// public class FileWatcherFactory {
// public static FileWatcher getFileWatcher() {
// return new WatchServiceFileWatcher();
// }
// }
// Path: src/main/java/com/thinksincode/tailstreamer/FileWatcherService.java
import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.FileWatcher;
import com.thinksincode.tailstreamer.watch.FileWatcherFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import java.nio.file.Path;
package com.thinksincode.tailstreamer;
/**
* Watches a file for changes, and notifies observers when the file is updated.
*/
@Service("fileWatcher")
public class FileWatcherService implements ApplicationEventPublisherAware, FileListener {
private Logger logger = LoggerFactory.getLogger(FileWatcherService.class);
private ApplicationEventPublisher eventPublisher;
/** Flag that indicates whether the watch service should continue. */
private boolean watch = true;
/**
* Starts watching a file.
*/
public void watchFile(final Path watchedFile) { | FileWatcher watcher = FileWatcherFactory.getFileWatcher(); |
joeattardi/tailstreamer | src/main/java/com/thinksincode/tailstreamer/FileWatcherService.java | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcher.java
// public interface FileWatcher {
// public void watchFile(Path file);
// public void removeFileListener(FileListener listener);
// public void addFileListener(FileListener listener);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcherFactory.java
// public class FileWatcherFactory {
// public static FileWatcher getFileWatcher() {
// return new WatchServiceFileWatcher();
// }
// }
| import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.FileWatcher;
import com.thinksincode.tailstreamer.watch.FileWatcherFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import java.nio.file.Path; | package com.thinksincode.tailstreamer;
/**
* Watches a file for changes, and notifies observers when the file is updated.
*/
@Service("fileWatcher")
public class FileWatcherService implements ApplicationEventPublisherAware, FileListener {
private Logger logger = LoggerFactory.getLogger(FileWatcherService.class);
private ApplicationEventPublisher eventPublisher;
/** Flag that indicates whether the watch service should continue. */
private boolean watch = true;
/**
* Starts watching a file.
*/
public void watchFile(final Path watchedFile) { | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcher.java
// public interface FileWatcher {
// public void watchFile(Path file);
// public void removeFileListener(FileListener listener);
// public void addFileListener(FileListener listener);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcherFactory.java
// public class FileWatcherFactory {
// public static FileWatcher getFileWatcher() {
// return new WatchServiceFileWatcher();
// }
// }
// Path: src/main/java/com/thinksincode/tailstreamer/FileWatcherService.java
import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.FileWatcher;
import com.thinksincode.tailstreamer.watch.FileWatcherFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import java.nio.file.Path;
package com.thinksincode.tailstreamer;
/**
* Watches a file for changes, and notifies observers when the file is updated.
*/
@Service("fileWatcher")
public class FileWatcherService implements ApplicationEventPublisherAware, FileListener {
private Logger logger = LoggerFactory.getLogger(FileWatcherService.class);
private ApplicationEventPublisher eventPublisher;
/** Flag that indicates whether the watch service should continue. */
private boolean watch = true;
/**
* Starts watching a file.
*/
public void watchFile(final Path watchedFile) { | FileWatcher watcher = FileWatcherFactory.getFileWatcher(); |
joeattardi/tailstreamer | src/main/java/com/thinksincode/tailstreamer/FileWatcherService.java | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcher.java
// public interface FileWatcher {
// public void watchFile(Path file);
// public void removeFileListener(FileListener listener);
// public void addFileListener(FileListener listener);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcherFactory.java
// public class FileWatcherFactory {
// public static FileWatcher getFileWatcher() {
// return new WatchServiceFileWatcher();
// }
// }
| import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.FileWatcher;
import com.thinksincode.tailstreamer.watch.FileWatcherFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import java.nio.file.Path; | package com.thinksincode.tailstreamer;
/**
* Watches a file for changes, and notifies observers when the file is updated.
*/
@Service("fileWatcher")
public class FileWatcherService implements ApplicationEventPublisherAware, FileListener {
private Logger logger = LoggerFactory.getLogger(FileWatcherService.class);
private ApplicationEventPublisher eventPublisher;
/** Flag that indicates whether the watch service should continue. */
private boolean watch = true;
/**
* Starts watching a file.
*/
public void watchFile(final Path watchedFile) {
FileWatcher watcher = FileWatcherFactory.getFileWatcher();
watcher.addFileListener(this);
watcher.watchFile(watchedFile);
}
/**
* Called when changes have been detected to the file.
*/
@Override | // Path: src/main/java/com/thinksincode/tailstreamer/watch/FileListener.java
// public interface FileListener {
// public void fileChanged(FileUpdateEvent event);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileUpdateEvent.java
// public class FileUpdateEvent extends ApplicationEvent {
//
// public FileUpdateEvent(final Object source) {
// super(source);
// }
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcher.java
// public interface FileWatcher {
// public void watchFile(Path file);
// public void removeFileListener(FileListener listener);
// public void addFileListener(FileListener listener);
// }
//
// Path: src/main/java/com/thinksincode/tailstreamer/watch/FileWatcherFactory.java
// public class FileWatcherFactory {
// public static FileWatcher getFileWatcher() {
// return new WatchServiceFileWatcher();
// }
// }
// Path: src/main/java/com/thinksincode/tailstreamer/FileWatcherService.java
import com.thinksincode.tailstreamer.watch.FileListener;
import com.thinksincode.tailstreamer.watch.FileUpdateEvent;
import com.thinksincode.tailstreamer.watch.FileWatcher;
import com.thinksincode.tailstreamer.watch.FileWatcherFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import java.nio.file.Path;
package com.thinksincode.tailstreamer;
/**
* Watches a file for changes, and notifies observers when the file is updated.
*/
@Service("fileWatcher")
public class FileWatcherService implements ApplicationEventPublisherAware, FileListener {
private Logger logger = LoggerFactory.getLogger(FileWatcherService.class);
private ApplicationEventPublisher eventPublisher;
/** Flag that indicates whether the watch service should continue. */
private boolean watch = true;
/**
* Starts watching a file.
*/
public void watchFile(final Path watchedFile) {
FileWatcher watcher = FileWatcherFactory.getFileWatcher();
watcher.addFileListener(this);
watcher.watchFile(watchedFile);
}
/**
* Called when changes have been detected to the file.
*/
@Override | public void fileChanged(FileUpdateEvent event) { |
Haixing-Hu/javafx-widgets | src/main/java/com/github/haixing_hu/javafx/action/ActionGroup.java | // Path: src/main/java/com/github/haixing_hu/javafx/control/menubutton/NoArrowMenuButton.java
// @SuppressWarnings("restriction")
// public class NoArrowMenuButton extends MenuButton {
//
// public static final String NO_ARROW_STYLE_CLASS = "no-arrow";
//
// /**
// * Creates a new empty menu button. Use {@link #setText(String)},
// * {@link #setGraphic(Node)} and {@link #getItems()} to set the content.
// */
// public NoArrowMenuButton() {
// super();
// getStyleClass().add(NO_ARROW_STYLE_CLASS);
// }
//
// /**
// * Creates a new empty menu button with the given text to display on the menu.
// * Use {@link #setGraphic(Node)} and {@link #getItems()} to set the content.
// *
// * @param text
// * the text to display on the menu button
// */
// public NoArrowMenuButton(String text) {
// super(text);
// getStyleClass().add(NO_ARROW_STYLE_CLASS);
// }
//
// /**
// * Creates a new empty menu button with the given text and graphic to display
// * on the menu. Use {@link #getItems()} to set the content.
// *
// * @param text
// * the text to display on the menu button
// * @param graphic
// * the graphic to display on the menu button
// */
// public NoArrowMenuButton(String text, Node graphic) {
// super(text, graphic);
// getStyleClass().add(NO_ARROW_STYLE_CLASS);
// }
//
// @Override
// protected Skin<?> createDefaultSkin() {
// return new NoArrowMenuButtonSkin(this);
// }
// }
| import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import javafx.beans.binding.Bindings;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.scene.control.ButtonBase;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SplitMenuButton;
import javafx.scene.control.ToolBar;
import javafx.scene.control.Tooltip;
import javax.annotation.Nullable;
import com.github.haixing_hu.javafx.control.menubutton.NoArrowMenuButton;
import com.github.haixing_hu.lang.Argument; | * {@link ActionGroup}.
*/
public final ObservableList<IAction> getActions() {
return actions;
}
/**
* Adds an action to this action group.
*
* @param action
* the action to be added to this action group.
*/
public final void add(IAction action) {
actions.add(action);
}
@Override
public ButtonBase createButton() {
switch (options & ActionOption.BUTTON_TYPE_MASK) {
case ActionOption.SPLIT_MENU_BUTTON: {
final SplitMenuButton button = new SplitMenuButton();
configMenuButton(button);
return button;
}
case ActionOption.MENU_BUTTON:
default: {
final MenuButton button;
if ((options & ActionOption.NO_ARROW) == 0) {
button = new MenuButton();
} else { | // Path: src/main/java/com/github/haixing_hu/javafx/control/menubutton/NoArrowMenuButton.java
// @SuppressWarnings("restriction")
// public class NoArrowMenuButton extends MenuButton {
//
// public static final String NO_ARROW_STYLE_CLASS = "no-arrow";
//
// /**
// * Creates a new empty menu button. Use {@link #setText(String)},
// * {@link #setGraphic(Node)} and {@link #getItems()} to set the content.
// */
// public NoArrowMenuButton() {
// super();
// getStyleClass().add(NO_ARROW_STYLE_CLASS);
// }
//
// /**
// * Creates a new empty menu button with the given text to display on the menu.
// * Use {@link #setGraphic(Node)} and {@link #getItems()} to set the content.
// *
// * @param text
// * the text to display on the menu button
// */
// public NoArrowMenuButton(String text) {
// super(text);
// getStyleClass().add(NO_ARROW_STYLE_CLASS);
// }
//
// /**
// * Creates a new empty menu button with the given text and graphic to display
// * on the menu. Use {@link #getItems()} to set the content.
// *
// * @param text
// * the text to display on the menu button
// * @param graphic
// * the graphic to display on the menu button
// */
// public NoArrowMenuButton(String text, Node graphic) {
// super(text, graphic);
// getStyleClass().add(NO_ARROW_STYLE_CLASS);
// }
//
// @Override
// protected Skin<?> createDefaultSkin() {
// return new NoArrowMenuButtonSkin(this);
// }
// }
// Path: src/main/java/com/github/haixing_hu/javafx/action/ActionGroup.java
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import javafx.beans.binding.Bindings;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.scene.control.ButtonBase;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SplitMenuButton;
import javafx.scene.control.ToolBar;
import javafx.scene.control.Tooltip;
import javax.annotation.Nullable;
import com.github.haixing_hu.javafx.control.menubutton.NoArrowMenuButton;
import com.github.haixing_hu.lang.Argument;
* {@link ActionGroup}.
*/
public final ObservableList<IAction> getActions() {
return actions;
}
/**
* Adds an action to this action group.
*
* @param action
* the action to be added to this action group.
*/
public final void add(IAction action) {
actions.add(action);
}
@Override
public ButtonBase createButton() {
switch (options & ActionOption.BUTTON_TYPE_MASK) {
case ActionOption.SPLIT_MENU_BUTTON: {
final SplitMenuButton button = new SplitMenuButton();
configMenuButton(button);
return button;
}
case ActionOption.MENU_BUTTON:
default: {
final MenuButton button;
if ((options & ActionOption.NO_ARROW) == 0) {
button = new MenuButton();
} else { | button = new NoArrowMenuButton(); |
Haixing-Hu/javafx-widgets | src/main/java/com/github/haixing_hu/javafx/control/textfield/AutoCompletionTextFieldBinding.java | // Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringConverter.java
// public final class ToStringConverter<T> extends StringConverter<T> {
//
// @Override
// public String toString(T object) {
// return (object == null ? "" : object.toString());
// }
//
// @Override
// public T fromString(String string) {
// throw new UnsupportedOperationException();
// }
//
// }
| import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.TextField;
import javafx.util.StringConverter;
import com.github.haixing_hu.javafx.util.ToStringConverter; | /******************************************************************************
*
* Copyright (c) 2014 Haixing Hu
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* ControlsFX - Initial implementation and API.
* Haixing Hu (https://github.com/Haixing-Hu/) - Refactor.
*
******************************************************************************/
/**
* Copyright (c) 2013, ControlsFX
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of ControlsFX, any associated website, nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.github.haixing_hu.javafx.control.textfield;
/**
* Represents a binding between a text field and a auto-completion popup
*
* @param <T>
* the type of suggestions.
*/
public class AutoCompletionTextFieldBinding<T> extends AutoCompletionBinding<T> {
private final StringConverter<T> converter;
private final ChangeListener<String> textChangeListener;
private final ChangeListener<Boolean> focusChangedListener;
/**
* Creates a new auto-completion binding between the given text field and the
* given suggestion provider.
*
* @param textField
* a given text field.
* @param suggestionProvider
* a given suggestion provider.
*/
public AutoCompletionTextFieldBinding(final TextField textField,
SuggestionProvider<T> suggestionProvider) { | // Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringConverter.java
// public final class ToStringConverter<T> extends StringConverter<T> {
//
// @Override
// public String toString(T object) {
// return (object == null ? "" : object.toString());
// }
//
// @Override
// public T fromString(String string) {
// throw new UnsupportedOperationException();
// }
//
// }
// Path: src/main/java/com/github/haixing_hu/javafx/control/textfield/AutoCompletionTextFieldBinding.java
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.TextField;
import javafx.util.StringConverter;
import com.github.haixing_hu.javafx.util.ToStringConverter;
/******************************************************************************
*
* Copyright (c) 2014 Haixing Hu
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* ControlsFX - Initial implementation and API.
* Haixing Hu (https://github.com/Haixing-Hu/) - Refactor.
*
******************************************************************************/
/**
* Copyright (c) 2013, ControlsFX
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of ControlsFX, any associated website, nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.github.haixing_hu.javafx.control.textfield;
/**
* Represents a binding between a text field and a auto-completion popup
*
* @param <T>
* the type of suggestions.
*/
public class AutoCompletionTextFieldBinding<T> extends AutoCompletionBinding<T> {
private final StringConverter<T> converter;
private final ChangeListener<String> textChangeListener;
private final ChangeListener<Boolean> focusChangedListener;
/**
* Creates a new auto-completion binding between the given text field and the
* given suggestion provider.
*
* @param textField
* a given text field.
* @param suggestionProvider
* a given suggestion provider.
*/
public AutoCompletionTextFieldBinding(final TextField textField,
SuggestionProvider<T> suggestionProvider) { | this(textField, suggestionProvider, new ToStringConverter<T>()); |
Haixing-Hu/javafx-widgets | src/main/java/com/github/haixing_hu/javafx/control/popover/PopOverSkin.java | // Path: src/main/java/com/github/haixing_hu/javafx/control/popover/ArrowLocation.java
// public enum ArrowLocation {
//
// LEFT_TOP,
//
// LEFT_CENTER,
//
// LEFT_BOTTOM,
//
// RIGHT_TOP,
//
// RIGHT_CENTER,
//
// RIGHT_BOTTOM,
//
// TOP_LEFT,
//
// TOP_CENTER,
//
// TOP_RIGHT,
//
// BOTTOM_LEFT,
//
// BOTTOM_CENTER,
//
// BOTTOM_RIGHT;
// }
| import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javafx.beans.InvalidationListener;
import javafx.beans.binding.Bindings;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.event.EventHandler;
import javafx.geometry.Point2D;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.Skin;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Circle;
import javafx.scene.shape.HLineTo;
import javafx.scene.shape.Line;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.scene.shape.PathElement;
import javafx.scene.shape.QuadCurveTo;
import javafx.scene.shape.VLineTo;
import javafx.stage.Window;
import static java.lang.Double.MAX_VALUE;
import static javafx.geometry.Pos.CENTER_RIGHT;
import static javafx.scene.control.ContentDisplay.GRAPHIC_ONLY;
import static com.github.haixing_hu.javafx.control.popover.ArrowLocation.*; | Bindings.add(topEdgePlusRadiusProperty, arrowIndentProperty),
Bindings.multiply(arrowSizeProperty, 2)));
lineILeft = new LineTo();
lineILeft.xProperty().bind(
Bindings.subtract(leftEdgeProperty, arrowSizeProperty));
lineILeft.yProperty().bind(
Bindings.add(
Bindings.add(topEdgePlusRadiusProperty, arrowIndentProperty),
arrowSizeProperty));
lineJLeft = new LineTo();
lineJLeft.xProperty().bind(leftEdgeProperty);
lineJLeft.yProperty().bind(
Bindings.add(topEdgePlusRadiusProperty, arrowIndentProperty));
lineKLeft = new VLineTo();
lineKLeft.yProperty().bind(topEdgePlusRadiusProperty);
topCurveTo = new QuadCurveTo();
topCurveTo.xProperty().bind(leftEdgePlusRadiusProperty);
topCurveTo.yProperty().bind(topEdgeProperty);
topCurveTo.controlXProperty().bind(leftEdgeProperty);
topCurveTo.controlYProperty().bind(topEdgeProperty);
}
private Window getPopupWindow() {
return getSkinnable().getScene().getWindow();
}
| // Path: src/main/java/com/github/haixing_hu/javafx/control/popover/ArrowLocation.java
// public enum ArrowLocation {
//
// LEFT_TOP,
//
// LEFT_CENTER,
//
// LEFT_BOTTOM,
//
// RIGHT_TOP,
//
// RIGHT_CENTER,
//
// RIGHT_BOTTOM,
//
// TOP_LEFT,
//
// TOP_CENTER,
//
// TOP_RIGHT,
//
// BOTTOM_LEFT,
//
// BOTTOM_CENTER,
//
// BOTTOM_RIGHT;
// }
// Path: src/main/java/com/github/haixing_hu/javafx/control/popover/PopOverSkin.java
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javafx.beans.InvalidationListener;
import javafx.beans.binding.Bindings;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.event.EventHandler;
import javafx.geometry.Point2D;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.Skin;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Circle;
import javafx.scene.shape.HLineTo;
import javafx.scene.shape.Line;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.scene.shape.PathElement;
import javafx.scene.shape.QuadCurveTo;
import javafx.scene.shape.VLineTo;
import javafx.stage.Window;
import static java.lang.Double.MAX_VALUE;
import static javafx.geometry.Pos.CENTER_RIGHT;
import static javafx.scene.control.ContentDisplay.GRAPHIC_ONLY;
import static com.github.haixing_hu.javafx.control.popover.ArrowLocation.*;
Bindings.add(topEdgePlusRadiusProperty, arrowIndentProperty),
Bindings.multiply(arrowSizeProperty, 2)));
lineILeft = new LineTo();
lineILeft.xProperty().bind(
Bindings.subtract(leftEdgeProperty, arrowSizeProperty));
lineILeft.yProperty().bind(
Bindings.add(
Bindings.add(topEdgePlusRadiusProperty, arrowIndentProperty),
arrowSizeProperty));
lineJLeft = new LineTo();
lineJLeft.xProperty().bind(leftEdgeProperty);
lineJLeft.yProperty().bind(
Bindings.add(topEdgePlusRadiusProperty, arrowIndentProperty));
lineKLeft = new VLineTo();
lineKLeft.yProperty().bind(topEdgePlusRadiusProperty);
topCurveTo = new QuadCurveTo();
topCurveTo.xProperty().bind(leftEdgePlusRadiusProperty);
topCurveTo.yProperty().bind(topEdgeProperty);
topCurveTo.controlXProperty().bind(leftEdgeProperty);
topCurveTo.controlYProperty().bind(topEdgeProperty);
}
private Window getPopupWindow() {
return getSkinnable().getScene().getWindow();
}
| private boolean showArrow(ArrowLocation location) { |
Haixing-Hu/javafx-widgets | src/main/java/com/github/haixing_hu/javafx/pane/FillPane.java | // Path: src/main/java/com/github/haixing_hu/javafx/geometry/Size.java
// public class Size {
//
// public double width;
//
// public double height;
//
// public Size() {
// width = 0;
// height = 0;
// }
//
// public Size(double width, double height) {
// this.width = width;
// this.height = height;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// long temp;
// temp = Double.doubleToLongBits(height);
// result = (prime * result) + (int) (temp ^ (temp >>> 32));
// temp = Double.doubleToLongBits(width);
// result = (prime * result) + (int) (temp ^ (temp >>> 32));
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final Size other = (Size) obj;
// if (Double.doubleToLongBits(height) != Double
// .doubleToLongBits(other.height)) {
// return false;
// }
// if (Double.doubleToLongBits(width) != Double.doubleToLongBits(other.width)) {
// return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// return "Size [width=" + width + ", height=" + height + "]";
// }
//
// }
| import java.util.WeakHashMap;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.WritableIntegerValue;
import javafx.beans.value.WritableObjectValue;
import javafx.geometry.Bounds;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import com.github.haixing_hu.javafx.geometry.Size; |
public WritableObjectValue<Orientation> orientationProperty() {
return orientation;
}
public void setMarginWidth(int marginWidth) {
this.marginWidth.set(marginWidth);
}
public int getMarginWidth() {
return marginWidth.get();
}
public WritableIntegerValue marginHeightProperty() {
return marginHeight;
}
public void setMarginHeight(int marginHeight) {
this.marginHeight.set(marginHeight);
}
public int getMarginHeight() {
return marginHeight.get();
}
public WritableIntegerValue marginWidthProperty() {
return marginWidth;
}
@Override | // Path: src/main/java/com/github/haixing_hu/javafx/geometry/Size.java
// public class Size {
//
// public double width;
//
// public double height;
//
// public Size() {
// width = 0;
// height = 0;
// }
//
// public Size(double width, double height) {
// this.width = width;
// this.height = height;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// long temp;
// temp = Double.doubleToLongBits(height);
// result = (prime * result) + (int) (temp ^ (temp >>> 32));
// temp = Double.doubleToLongBits(width);
// result = (prime * result) + (int) (temp ^ (temp >>> 32));
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final Size other = (Size) obj;
// if (Double.doubleToLongBits(height) != Double
// .doubleToLongBits(other.height)) {
// return false;
// }
// if (Double.doubleToLongBits(width) != Double.doubleToLongBits(other.width)) {
// return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// return "Size [width=" + width + ", height=" + height + "]";
// }
//
// }
// Path: src/main/java/com/github/haixing_hu/javafx/pane/FillPane.java
import java.util.WeakHashMap;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.WritableIntegerValue;
import javafx.beans.value.WritableObjectValue;
import javafx.geometry.Bounds;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import com.github.haixing_hu.javafx.geometry.Size;
public WritableObjectValue<Orientation> orientationProperty() {
return orientation;
}
public void setMarginWidth(int marginWidth) {
this.marginWidth.set(marginWidth);
}
public int getMarginWidth() {
return marginWidth.get();
}
public WritableIntegerValue marginHeightProperty() {
return marginHeight;
}
public void setMarginHeight(int marginHeight) {
this.marginHeight.set(marginHeight);
}
public int getMarginHeight() {
return marginHeight.get();
}
public WritableIntegerValue marginWidthProperty() {
return marginWidth;
}
@Override | protected Size computeSize(double wHint, double hHint, boolean flushCache) { |
Haixing-Hu/javafx-widgets | src/main/java/com/github/haixing_hu/javafx/control/textfield/DefaultSuggestionProvider.java | // Path: src/main/java/com/github/haixing_hu/javafx/util/StringConverterComparator.java
// public final class StringConverterComparator<T> implements Comparator<T> {
//
// private final StringConverter<T> converter;
//
// /**
// * Constructs a {@link StringConverterComparator} with a specified string
// * converter.
// *
// * @param converter
// * a specified string converter.
// */
// public StringConverterComparator(StringConverter<T> converter) {
// this.converter = requireNonNull("converter", converter);
// }
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = converter.toString(o1);
// final String o2str = converter.toString(o2);
// return o1str.compareTo(o2str);
// }
//
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringComparator.java
// public final class ToStringComparator<T> implements Comparator<T> {
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = o1.toString();
// final String o2str = o2.toString();
// return o1str.compareTo(o2str);
// }
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringConverter.java
// public final class ToStringConverter<T> extends StringConverter<T> {
//
// @Override
// public String toString(T object) {
// return (object == null ? "" : object.toString());
// }
//
// @Override
// public T fromString(String string) {
// throw new UnsupportedOperationException();
// }
//
// }
| import java.util.Comparator;
import javafx.util.StringConverter;
import com.github.haixing_hu.javafx.util.StringConverterComparator;
import com.github.haixing_hu.javafx.util.ToStringComparator;
import com.github.haixing_hu.javafx.util.ToStringConverter;
import static com.github.haixing_hu.lang.Argument.requireNonNull; | package com.github.haixing_hu.javafx.control.textfield;
/**
* This is a simple string based suggestion provider. All generic suggestions T
* are turned into strings for processing.
*
* @param <T>
* the type of suggestions.
*/
public class DefaultSuggestionProvider<T> extends AbstractSuggestionProvider<T> {
private final StringConverter<T> converter;
private final Comparator<T> comparator;
/**
* Create a new {@link DefaultSuggestionProvider}, using the default
* {@link ToStringConverter} and {@link ToStringComparator}.
*/
public DefaultSuggestionProvider() { | // Path: src/main/java/com/github/haixing_hu/javafx/util/StringConverterComparator.java
// public final class StringConverterComparator<T> implements Comparator<T> {
//
// private final StringConverter<T> converter;
//
// /**
// * Constructs a {@link StringConverterComparator} with a specified string
// * converter.
// *
// * @param converter
// * a specified string converter.
// */
// public StringConverterComparator(StringConverter<T> converter) {
// this.converter = requireNonNull("converter", converter);
// }
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = converter.toString(o1);
// final String o2str = converter.toString(o2);
// return o1str.compareTo(o2str);
// }
//
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringComparator.java
// public final class ToStringComparator<T> implements Comparator<T> {
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = o1.toString();
// final String o2str = o2.toString();
// return o1str.compareTo(o2str);
// }
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringConverter.java
// public final class ToStringConverter<T> extends StringConverter<T> {
//
// @Override
// public String toString(T object) {
// return (object == null ? "" : object.toString());
// }
//
// @Override
// public T fromString(String string) {
// throw new UnsupportedOperationException();
// }
//
// }
// Path: src/main/java/com/github/haixing_hu/javafx/control/textfield/DefaultSuggestionProvider.java
import java.util.Comparator;
import javafx.util.StringConverter;
import com.github.haixing_hu.javafx.util.StringConverterComparator;
import com.github.haixing_hu.javafx.util.ToStringComparator;
import com.github.haixing_hu.javafx.util.ToStringConverter;
import static com.github.haixing_hu.lang.Argument.requireNonNull;
package com.github.haixing_hu.javafx.control.textfield;
/**
* This is a simple string based suggestion provider. All generic suggestions T
* are turned into strings for processing.
*
* @param <T>
* the type of suggestions.
*/
public class DefaultSuggestionProvider<T> extends AbstractSuggestionProvider<T> {
private final StringConverter<T> converter;
private final Comparator<T> comparator;
/**
* Create a new {@link DefaultSuggestionProvider}, using the default
* {@link ToStringConverter} and {@link ToStringComparator}.
*/
public DefaultSuggestionProvider() { | converter = new ToStringConverter<T>(); |
Haixing-Hu/javafx-widgets | src/main/java/com/github/haixing_hu/javafx/control/textfield/DefaultSuggestionProvider.java | // Path: src/main/java/com/github/haixing_hu/javafx/util/StringConverterComparator.java
// public final class StringConverterComparator<T> implements Comparator<T> {
//
// private final StringConverter<T> converter;
//
// /**
// * Constructs a {@link StringConverterComparator} with a specified string
// * converter.
// *
// * @param converter
// * a specified string converter.
// */
// public StringConverterComparator(StringConverter<T> converter) {
// this.converter = requireNonNull("converter", converter);
// }
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = converter.toString(o1);
// final String o2str = converter.toString(o2);
// return o1str.compareTo(o2str);
// }
//
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringComparator.java
// public final class ToStringComparator<T> implements Comparator<T> {
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = o1.toString();
// final String o2str = o2.toString();
// return o1str.compareTo(o2str);
// }
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringConverter.java
// public final class ToStringConverter<T> extends StringConverter<T> {
//
// @Override
// public String toString(T object) {
// return (object == null ? "" : object.toString());
// }
//
// @Override
// public T fromString(String string) {
// throw new UnsupportedOperationException();
// }
//
// }
| import java.util.Comparator;
import javafx.util.StringConverter;
import com.github.haixing_hu.javafx.util.StringConverterComparator;
import com.github.haixing_hu.javafx.util.ToStringComparator;
import com.github.haixing_hu.javafx.util.ToStringConverter;
import static com.github.haixing_hu.lang.Argument.requireNonNull; | package com.github.haixing_hu.javafx.control.textfield;
/**
* This is a simple string based suggestion provider. All generic suggestions T
* are turned into strings for processing.
*
* @param <T>
* the type of suggestions.
*/
public class DefaultSuggestionProvider<T> extends AbstractSuggestionProvider<T> {
private final StringConverter<T> converter;
private final Comparator<T> comparator;
/**
* Create a new {@link DefaultSuggestionProvider}, using the default
* {@link ToStringConverter} and {@link ToStringComparator}.
*/
public DefaultSuggestionProvider() {
converter = new ToStringConverter<T>(); | // Path: src/main/java/com/github/haixing_hu/javafx/util/StringConverterComparator.java
// public final class StringConverterComparator<T> implements Comparator<T> {
//
// private final StringConverter<T> converter;
//
// /**
// * Constructs a {@link StringConverterComparator} with a specified string
// * converter.
// *
// * @param converter
// * a specified string converter.
// */
// public StringConverterComparator(StringConverter<T> converter) {
// this.converter = requireNonNull("converter", converter);
// }
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = converter.toString(o1);
// final String o2str = converter.toString(o2);
// return o1str.compareTo(o2str);
// }
//
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringComparator.java
// public final class ToStringComparator<T> implements Comparator<T> {
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = o1.toString();
// final String o2str = o2.toString();
// return o1str.compareTo(o2str);
// }
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringConverter.java
// public final class ToStringConverter<T> extends StringConverter<T> {
//
// @Override
// public String toString(T object) {
// return (object == null ? "" : object.toString());
// }
//
// @Override
// public T fromString(String string) {
// throw new UnsupportedOperationException();
// }
//
// }
// Path: src/main/java/com/github/haixing_hu/javafx/control/textfield/DefaultSuggestionProvider.java
import java.util.Comparator;
import javafx.util.StringConverter;
import com.github.haixing_hu.javafx.util.StringConverterComparator;
import com.github.haixing_hu.javafx.util.ToStringComparator;
import com.github.haixing_hu.javafx.util.ToStringConverter;
import static com.github.haixing_hu.lang.Argument.requireNonNull;
package com.github.haixing_hu.javafx.control.textfield;
/**
* This is a simple string based suggestion provider. All generic suggestions T
* are turned into strings for processing.
*
* @param <T>
* the type of suggestions.
*/
public class DefaultSuggestionProvider<T> extends AbstractSuggestionProvider<T> {
private final StringConverter<T> converter;
private final Comparator<T> comparator;
/**
* Create a new {@link DefaultSuggestionProvider}, using the default
* {@link ToStringConverter} and {@link ToStringComparator}.
*/
public DefaultSuggestionProvider() {
converter = new ToStringConverter<T>(); | comparator = new ToStringComparator<T>(); |
Haixing-Hu/javafx-widgets | src/main/java/com/github/haixing_hu/javafx/control/textfield/DefaultSuggestionProvider.java | // Path: src/main/java/com/github/haixing_hu/javafx/util/StringConverterComparator.java
// public final class StringConverterComparator<T> implements Comparator<T> {
//
// private final StringConverter<T> converter;
//
// /**
// * Constructs a {@link StringConverterComparator} with a specified string
// * converter.
// *
// * @param converter
// * a specified string converter.
// */
// public StringConverterComparator(StringConverter<T> converter) {
// this.converter = requireNonNull("converter", converter);
// }
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = converter.toString(o1);
// final String o2str = converter.toString(o2);
// return o1str.compareTo(o2str);
// }
//
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringComparator.java
// public final class ToStringComparator<T> implements Comparator<T> {
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = o1.toString();
// final String o2str = o2.toString();
// return o1str.compareTo(o2str);
// }
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringConverter.java
// public final class ToStringConverter<T> extends StringConverter<T> {
//
// @Override
// public String toString(T object) {
// return (object == null ? "" : object.toString());
// }
//
// @Override
// public T fromString(String string) {
// throw new UnsupportedOperationException();
// }
//
// }
| import java.util.Comparator;
import javafx.util.StringConverter;
import com.github.haixing_hu.javafx.util.StringConverterComparator;
import com.github.haixing_hu.javafx.util.ToStringComparator;
import com.github.haixing_hu.javafx.util.ToStringConverter;
import static com.github.haixing_hu.lang.Argument.requireNonNull; | package com.github.haixing_hu.javafx.control.textfield;
/**
* This is a simple string based suggestion provider. All generic suggestions T
* are turned into strings for processing.
*
* @param <T>
* the type of suggestions.
*/
public class DefaultSuggestionProvider<T> extends AbstractSuggestionProvider<T> {
private final StringConverter<T> converter;
private final Comparator<T> comparator;
/**
* Create a new {@link DefaultSuggestionProvider}, using the default
* {@link ToStringConverter} and {@link ToStringComparator}.
*/
public DefaultSuggestionProvider() {
converter = new ToStringConverter<T>();
comparator = new ToStringComparator<T>();
}
/**
* Create a new {@link DefaultSuggestionProvider}, using the specified string
* converter to construct a suggestion comparator.
*
* @param converter
* a string converter.
*/
public DefaultSuggestionProvider(StringConverter<T> converter) {
this.converter = requireNonNull("converter", converter); | // Path: src/main/java/com/github/haixing_hu/javafx/util/StringConverterComparator.java
// public final class StringConverterComparator<T> implements Comparator<T> {
//
// private final StringConverter<T> converter;
//
// /**
// * Constructs a {@link StringConverterComparator} with a specified string
// * converter.
// *
// * @param converter
// * a specified string converter.
// */
// public StringConverterComparator(StringConverter<T> converter) {
// this.converter = requireNonNull("converter", converter);
// }
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = converter.toString(o1);
// final String o2str = converter.toString(o2);
// return o1str.compareTo(o2str);
// }
//
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringComparator.java
// public final class ToStringComparator<T> implements Comparator<T> {
//
// @Override
// public int compare(T o1, T o2) {
// final String o1str = o1.toString();
// final String o2str = o2.toString();
// return o1str.compareTo(o2str);
// }
// }
//
// Path: src/main/java/com/github/haixing_hu/javafx/util/ToStringConverter.java
// public final class ToStringConverter<T> extends StringConverter<T> {
//
// @Override
// public String toString(T object) {
// return (object == null ? "" : object.toString());
// }
//
// @Override
// public T fromString(String string) {
// throw new UnsupportedOperationException();
// }
//
// }
// Path: src/main/java/com/github/haixing_hu/javafx/control/textfield/DefaultSuggestionProvider.java
import java.util.Comparator;
import javafx.util.StringConverter;
import com.github.haixing_hu.javafx.util.StringConverterComparator;
import com.github.haixing_hu.javafx.util.ToStringComparator;
import com.github.haixing_hu.javafx.util.ToStringConverter;
import static com.github.haixing_hu.lang.Argument.requireNonNull;
package com.github.haixing_hu.javafx.control.textfield;
/**
* This is a simple string based suggestion provider. All generic suggestions T
* are turned into strings for processing.
*
* @param <T>
* the type of suggestions.
*/
public class DefaultSuggestionProvider<T> extends AbstractSuggestionProvider<T> {
private final StringConverter<T> converter;
private final Comparator<T> comparator;
/**
* Create a new {@link DefaultSuggestionProvider}, using the default
* {@link ToStringConverter} and {@link ToStringComparator}.
*/
public DefaultSuggestionProvider() {
converter = new ToStringConverter<T>();
comparator = new ToStringComparator<T>();
}
/**
* Create a new {@link DefaultSuggestionProvider}, using the specified string
* converter to construct a suggestion comparator.
*
* @param converter
* a string converter.
*/
public DefaultSuggestionProvider(StringConverter<T> converter) {
this.converter = requireNonNull("converter", converter); | this.comparator = new StringConverterComparator<T>(converter); |
Haixing-Hu/javafx-widgets | src/main/java/com/github/haixing_hu/javafx/pane/FillData.java | // Path: src/main/java/com/github/haixing_hu/javafx/geometry/Size.java
// public class Size {
//
// public double width;
//
// public double height;
//
// public Size() {
// width = 0;
// height = 0;
// }
//
// public Size(double width, double height) {
// this.width = width;
// this.height = height;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// long temp;
// temp = Double.doubleToLongBits(height);
// result = (prime * result) + (int) (temp ^ (temp >>> 32));
// temp = Double.doubleToLongBits(width);
// result = (prime * result) + (int) (temp ^ (temp >>> 32));
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final Size other = (Size) obj;
// if (Double.doubleToLongBits(height) != Double
// .doubleToLongBits(other.height)) {
// return false;
// }
// if (Double.doubleToLongBits(width) != Double.doubleToLongBits(other.width)) {
// return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// return "Size [width=" + width + ", height=" + height + "]";
// }
//
// }
| import javafx.scene.Node;
import com.github.haixing_hu.javafx.geometry.Size;
import static javafx.scene.layout.Region.USE_COMPUTED_SIZE; | /******************************************************************************
*
* Copyright (c) 2014 Haixing Hu
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Haixing Hu (https://github.com/Haixing-Hu/) - Initial implementation and API.
*
******************************************************************************/
package com.github.haixing_hu.javafx.pane;
/**
* The layout data of the {@link FillPane}.
*
* @author Haixing Hu
*/
class FillData {
double defaultWidth = - 1;
double defaultHeight = - 1;
double currentWhint;
double currentHhint;
double currentWidth = - 1;
double currentHeight = - 1;
| // Path: src/main/java/com/github/haixing_hu/javafx/geometry/Size.java
// public class Size {
//
// public double width;
//
// public double height;
//
// public Size() {
// width = 0;
// height = 0;
// }
//
// public Size(double width, double height) {
// this.width = width;
// this.height = height;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// long temp;
// temp = Double.doubleToLongBits(height);
// result = (prime * result) + (int) (temp ^ (temp >>> 32));
// temp = Double.doubleToLongBits(width);
// result = (prime * result) + (int) (temp ^ (temp >>> 32));
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final Size other = (Size) obj;
// if (Double.doubleToLongBits(height) != Double
// .doubleToLongBits(other.height)) {
// return false;
// }
// if (Double.doubleToLongBits(width) != Double.doubleToLongBits(other.width)) {
// return false;
// }
// return true;
// }
//
// @Override
// public String toString() {
// return "Size [width=" + width + ", height=" + height + "]";
// }
//
// }
// Path: src/main/java/com/github/haixing_hu/javafx/pane/FillData.java
import javafx.scene.Node;
import com.github.haixing_hu.javafx.geometry.Size;
import static javafx.scene.layout.Region.USE_COMPUTED_SIZE;
/******************************************************************************
*
* Copyright (c) 2014 Haixing Hu
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Haixing Hu (https://github.com/Haixing-Hu/) - Initial implementation and API.
*
******************************************************************************/
package com.github.haixing_hu.javafx.pane;
/**
* The layout data of the {@link FillPane}.
*
* @author Haixing Hu
*/
class FillData {
double defaultWidth = - 1;
double defaultHeight = - 1;
double currentWhint;
double currentHhint;
double currentWidth = - 1;
double currentHeight = - 1;
| Size computeSize(Node control, double wHint, double hHint, boolean flushCache) { |
idega/is.idega.idegaweb.egov.course | src/java/is/idega/idegaweb/egov/course/data/ApplicationHolder.java | // Path: src/java/is/idega/idegaweb/egov/course/CourseConstants.java
// public class CourseConstants {
//
// public static final String CASE_CODE_KEY = "COURSEA";
//
// public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.course";
//
// public static final String ADMINISTRATOR_ROLE_KEY = "afterSchoolCareAdministrator";
// public static final String SUPER_ADMINISTRATOR_ROLE_KEY = "superAfterSchoolCareAdministrator";
// public static final String COURSE_ACCOUNTING_ROLE_KEY = "courseAccounting";
//
// public static final int DAY_CARE_NONE = 0;
// public static final int DAY_CARE_PRE = 1;
// public static final int DAY_CARE_POST = 2;
// public static final int DAY_CARE_PRE_AND_POST = 3;
//
// public static final String PROPERTY_REGISTRATION_EMAIL = "egov.course.registration.email";
// public static final String PROPERTY_BCC_EMAIL = "egov.course.bcc.email";
// public static final String PROPERTY_REFUND_EMAIL = "egov.course.refund.email";
// public static final String PROPERTY_HIDDEN_SCHOOL_TYPE = "egov.course.hidden.type";
// public static final String PROPERTY_MERCHANT_PK = "egov.course.merchant.pk";
// public static final String PROPERTY_MERCHANT_TYPE = "egov.course.merchant.type";
// public static final String PROPERTY_INVALIDATE_INTERVAL = "egov.course.invalidate.interval";
// public static final String PROPERTY_USE_DWR = "egov.course.use.dwr";
// public static final String PROPERTY_USE_FIXED_PRICES = "egov.course.use.fixed.prices";
// public static final String PROPERTY_USE_BIRTHYEARS = "egov.course.use.birthyears";
// public static final String PROPERTY_ACCOUNTING_TYPE_PK = "egov.course.accounting.type";
// public static final String PROPERTY_SHOW_ID_IN_NAME = "egov.course.show.id.in.name";
// public static final String PROPERTY_SHOW_PROVIDER = "egov.course.show.provider";
// public static final String PROPERTY_INCEPTION_YEAR = "egov.course.inception.year";
// public static final String PROPERTY_SHOW_ALL_COURSES = "egov.course.show.all.courses";
// public static final String PROPERTY_SHOW_CERTIFICATES = "egov.course.show.certificates";
// public static final String PROPERTY_SHOW_NO_PAYMENT = "egov.course.show.no.payment";
// public static final String PROPERTY_BACK_MONTHS = "egov.course.back.months";
// public static final String PROPERTY_USE_WAITING_LIST = "egov.course.use.waiting.list";
// public static final String PROPERTY_USE_DIRECT_PAYMENT = "egov.course.use.direct.payment";
// public static final String PROPERTY_SEND_REMINDERS = "egov.course.send.reminders";
// public static final String PROPERTY_PUBLIC_HOLIDAYS = "egov.course.public.holidays";
// public static final String PROPERTY_MANUALLY_OPEN_COURSES = "egov.course.manually.open";
// public static final String PROPERTY_ACCEPT_URL = "egov.course.accept.url";
// public static final String PROPERTY_SHOW_CARE_OPTIONS = "egov.course.show.care.options";
// public static final String PROPERTY_SHOW_PROVIDER_INFORMATION = "egov.course.show.provider.info";
// public static final String PROPERTY_SHOW_PERSON_INFORMATION = "egov.course.show.person.info";
//
// public static final String PROPERTY_TIMEOUT_DAY_OF_WEEK = "egov.course.timeout.day";
// public static final String PROPERTY_TIMEOUT_HOUR = "egov.course.timeout.hour";
//
// public static final String APPLICATION_PROPERTY_COURSE_MAP = "egov.course.map";
//
// public static final String CARD_TYPE_EUROCARD = "eurocard";
// public static final String CARD_TYPE_VISA = "visa";
//
// public static final String PAYMENT_TYPE_CARD = "credit_card";
// public static final String PAYMENT_TYPE_GIRO = "giro";
// public static final String PAYMENT_TYPE_BANK_TRANSFER = "bank_transfer";
//
// public static final String PRODUCT_CODE_CARE = "CARE";
// public static final String PRODUCT_CODE_COURSE = "COURSE";
//
// public static final String DISCOUNT_SIBLING = "sibling";
// public static final String DISCOUNT_QUANTITY = "quantity";
// public static final String DISCOUNT_SPOUSE = "spouse";
//
// public static final String COURSE_PREFIX = "course_";
//
// public static final String DEFAULT_COURSE_CERTIFICATE_FEE = "defaultCourseCertificateFee";
//
// public static final String PROPERTY_TIMER_HOUR = "egov.course.timer.hour";
// public static final String PROPERTY_TIMER_DAYOFWEEK = "egov.course.timer.dayofweek";
// public static final String PROPERTY_TIMER_MINUTE = "egov.course.timer.minute";
//
// }
| import is.idega.idegaweb.egov.course.CourseConstants;
import com.idega.block.school.data.School;
import com.idega.user.data.User; | this.choice = choice;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Course getCourse() {
return course;
}
public School getProvider() {
return getCourse().getProvider();
}
public int getPrice() {
float coursePrice = course.getCoursePrice();
if (coursePrice > 0) {
int tmpCoursePrice = Float.valueOf(coursePrice).intValue();
if (tmpCoursePrice > 0) {
return tmpCoursePrice;
}
}
CoursePrice price = course.getPrice();
int totalPrice = price.getPrice(); | // Path: src/java/is/idega/idegaweb/egov/course/CourseConstants.java
// public class CourseConstants {
//
// public static final String CASE_CODE_KEY = "COURSEA";
//
// public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.course";
//
// public static final String ADMINISTRATOR_ROLE_KEY = "afterSchoolCareAdministrator";
// public static final String SUPER_ADMINISTRATOR_ROLE_KEY = "superAfterSchoolCareAdministrator";
// public static final String COURSE_ACCOUNTING_ROLE_KEY = "courseAccounting";
//
// public static final int DAY_CARE_NONE = 0;
// public static final int DAY_CARE_PRE = 1;
// public static final int DAY_CARE_POST = 2;
// public static final int DAY_CARE_PRE_AND_POST = 3;
//
// public static final String PROPERTY_REGISTRATION_EMAIL = "egov.course.registration.email";
// public static final String PROPERTY_BCC_EMAIL = "egov.course.bcc.email";
// public static final String PROPERTY_REFUND_EMAIL = "egov.course.refund.email";
// public static final String PROPERTY_HIDDEN_SCHOOL_TYPE = "egov.course.hidden.type";
// public static final String PROPERTY_MERCHANT_PK = "egov.course.merchant.pk";
// public static final String PROPERTY_MERCHANT_TYPE = "egov.course.merchant.type";
// public static final String PROPERTY_INVALIDATE_INTERVAL = "egov.course.invalidate.interval";
// public static final String PROPERTY_USE_DWR = "egov.course.use.dwr";
// public static final String PROPERTY_USE_FIXED_PRICES = "egov.course.use.fixed.prices";
// public static final String PROPERTY_USE_BIRTHYEARS = "egov.course.use.birthyears";
// public static final String PROPERTY_ACCOUNTING_TYPE_PK = "egov.course.accounting.type";
// public static final String PROPERTY_SHOW_ID_IN_NAME = "egov.course.show.id.in.name";
// public static final String PROPERTY_SHOW_PROVIDER = "egov.course.show.provider";
// public static final String PROPERTY_INCEPTION_YEAR = "egov.course.inception.year";
// public static final String PROPERTY_SHOW_ALL_COURSES = "egov.course.show.all.courses";
// public static final String PROPERTY_SHOW_CERTIFICATES = "egov.course.show.certificates";
// public static final String PROPERTY_SHOW_NO_PAYMENT = "egov.course.show.no.payment";
// public static final String PROPERTY_BACK_MONTHS = "egov.course.back.months";
// public static final String PROPERTY_USE_WAITING_LIST = "egov.course.use.waiting.list";
// public static final String PROPERTY_USE_DIRECT_PAYMENT = "egov.course.use.direct.payment";
// public static final String PROPERTY_SEND_REMINDERS = "egov.course.send.reminders";
// public static final String PROPERTY_PUBLIC_HOLIDAYS = "egov.course.public.holidays";
// public static final String PROPERTY_MANUALLY_OPEN_COURSES = "egov.course.manually.open";
// public static final String PROPERTY_ACCEPT_URL = "egov.course.accept.url";
// public static final String PROPERTY_SHOW_CARE_OPTIONS = "egov.course.show.care.options";
// public static final String PROPERTY_SHOW_PROVIDER_INFORMATION = "egov.course.show.provider.info";
// public static final String PROPERTY_SHOW_PERSON_INFORMATION = "egov.course.show.person.info";
//
// public static final String PROPERTY_TIMEOUT_DAY_OF_WEEK = "egov.course.timeout.day";
// public static final String PROPERTY_TIMEOUT_HOUR = "egov.course.timeout.hour";
//
// public static final String APPLICATION_PROPERTY_COURSE_MAP = "egov.course.map";
//
// public static final String CARD_TYPE_EUROCARD = "eurocard";
// public static final String CARD_TYPE_VISA = "visa";
//
// public static final String PAYMENT_TYPE_CARD = "credit_card";
// public static final String PAYMENT_TYPE_GIRO = "giro";
// public static final String PAYMENT_TYPE_BANK_TRANSFER = "bank_transfer";
//
// public static final String PRODUCT_CODE_CARE = "CARE";
// public static final String PRODUCT_CODE_COURSE = "COURSE";
//
// public static final String DISCOUNT_SIBLING = "sibling";
// public static final String DISCOUNT_QUANTITY = "quantity";
// public static final String DISCOUNT_SPOUSE = "spouse";
//
// public static final String COURSE_PREFIX = "course_";
//
// public static final String DEFAULT_COURSE_CERTIFICATE_FEE = "defaultCourseCertificateFee";
//
// public static final String PROPERTY_TIMER_HOUR = "egov.course.timer.hour";
// public static final String PROPERTY_TIMER_DAYOFWEEK = "egov.course.timer.dayofweek";
// public static final String PROPERTY_TIMER_MINUTE = "egov.course.timer.minute";
//
// }
// Path: src/java/is/idega/idegaweb/egov/course/data/ApplicationHolder.java
import is.idega.idegaweb.egov.course.CourseConstants;
import com.idega.block.school.data.School;
import com.idega.user.data.User;
this.choice = choice;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Course getCourse() {
return course;
}
public School getProvider() {
return getCourse().getProvider();
}
public int getPrice() {
float coursePrice = course.getCoursePrice();
if (coursePrice > 0) {
int tmpCoursePrice = Float.valueOf(coursePrice).intValue();
if (tmpCoursePrice > 0) {
return tmpCoursePrice;
}
}
CoursePrice price = course.getPrice();
int totalPrice = price.getPrice(); | if (getDaycare() == CourseConstants.DAY_CARE_POST) { |
idega/is.idega.idegaweb.egov.course | src/java/is/idega/idegaweb/egov/course/data/Course.java | // Path: src/java/is/idega/idegaweb/egov/course/data/rent/RentableItem.java
// public interface RentableItem extends IDOEntity {
//
// public String getType();
// public void setType(String type);
//
// public String getName();
// public void setName(String name);
//
// public Double getRentPrice(SchoolSeason season);
// public void setRentPrice(SchoolSeason season, Double rentPrice);
//
// public Integer getQuantity();
// public void setQuantity(Integer quantity);
//
// public Integer getRentedAmount();
// public void setRentedAmount(Integer rented);
//
// public void addPrice(CoursePrice price) throws IDOAddRelationshipException;
// public Collection<CoursePrice> getAllPrices();
// public void removePrice(CoursePrice price) throws IDORemoveRelationshipException;
// public void removeAllPrices() throws IDORemoveRelationshipException;
// }
| import is.idega.idegaweb.egov.course.data.rent.RentableItem;
import java.sql.Timestamp;
import java.util.Collection;
import com.idega.block.school.data.School;
import com.idega.block.school.data.SchoolSeason;
import com.idega.data.IDOAddRelationshipException;
import com.idega.data.IDOEntity;
import com.idega.data.IDORemoveRelationshipException; | /**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setBirthyearTo
*/
public void setBirthyearTo(int to);
/**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setMax
*/
public void setMax(int max);
/**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setCourseNumber
*/
public void setCourseNumber(int number);
/**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setOpenForRegistration
*/
public void setOpenForRegistration(boolean openForRegistration);
/**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setHasPreCare
*/
public void setHasPreCare(boolean hasPreCare);
/**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setHasPostCare
*/
public void setHasPostCare(boolean hasPostCare);
| // Path: src/java/is/idega/idegaweb/egov/course/data/rent/RentableItem.java
// public interface RentableItem extends IDOEntity {
//
// public String getType();
// public void setType(String type);
//
// public String getName();
// public void setName(String name);
//
// public Double getRentPrice(SchoolSeason season);
// public void setRentPrice(SchoolSeason season, Double rentPrice);
//
// public Integer getQuantity();
// public void setQuantity(Integer quantity);
//
// public Integer getRentedAmount();
// public void setRentedAmount(Integer rented);
//
// public void addPrice(CoursePrice price) throws IDOAddRelationshipException;
// public Collection<CoursePrice> getAllPrices();
// public void removePrice(CoursePrice price) throws IDORemoveRelationshipException;
// public void removeAllPrices() throws IDORemoveRelationshipException;
// }
// Path: src/java/is/idega/idegaweb/egov/course/data/Course.java
import is.idega.idegaweb.egov.course.data.rent.RentableItem;
import java.sql.Timestamp;
import java.util.Collection;
import com.idega.block.school.data.School;
import com.idega.block.school.data.SchoolSeason;
import com.idega.data.IDOAddRelationshipException;
import com.idega.data.IDOEntity;
import com.idega.data.IDORemoveRelationshipException;
/**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setBirthyearTo
*/
public void setBirthyearTo(int to);
/**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setMax
*/
public void setMax(int max);
/**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setCourseNumber
*/
public void setCourseNumber(int number);
/**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setOpenForRegistration
*/
public void setOpenForRegistration(boolean openForRegistration);
/**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setHasPreCare
*/
public void setHasPreCare(boolean hasPreCare);
/**
* @see is.idega.idegaweb.egov.course.data.CourseBMPBean#setHasPostCare
*/
public void setHasPostCare(boolean hasPostCare);
| public void setRentableItems(Collection<? extends RentableItem> items) throws IDOAddRelationshipException; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.