@OnTouch(R.id.spinner_font_names) protected boolean onSpinnerTouchListener(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { if (currentSelectedFont != null && builderPickerDialog != null) { //to update currently selected font builderPickerDialog.setInputs(new UniversalPickerDialog.Input(currentFontIndex, (AbstractList<String>) fontNames)); builderPickerDialog.show(); } else { //fallback plan presenter.loadFontsAvailable(); setFontPickerDialog(); } } return true; }
public void testGetRecentConnections() throws Exception { String section = "remote.platforms"; ExecutionEnvironment[] envs = NativeExecutionTestSupport.getTestExecutionEnvironmentsFromSection(section); assertTrue("Empty environmens list for section ", envs.length > 0); ConnectionManager.getInstance().clearRecentConnectionsList(); AbstractList<ExecutionEnvironment> referenceList = new ArrayList<>(); for (ExecutionEnvironment env : envs) { ConnectionManager.getInstance().updateRecentConnectionsList(env); referenceList.add(0, env); } List<ExecutionEnvironment> managersList = ConnectionManager.getInstance().getRecentConnections(); assertEquals("Connections lists differ", referenceList, managersList); ConnectionManager.getInstance().clearRecentConnectionsList(); assertTrue("Recent connections list should be empty", ConnectionManager.getInstance().getRecentConnections().isEmpty()); ConnectionManager.getInstance().restoreRecentConnectionsList(); assertEquals("Restopred connections list differ", referenceList, managersList); }
@Override public List getValues() { final List origValues = buffer.getValues(); return new AbstractList() { @Override public Object get(int index) { return origValues.get(rawOffset(index)); } @Override public int size() { return getLength(); } }; }
@Override public List<ObjectVariable> getInstances(long maxInstances) { //assert !java.awt.EventQueue.isDispatchThread() : "Instances retrieving in AWT Event Queue!"; final List<ObjectReference> instances; try { instances = ReferenceTypeWrapper.instances(classType, maxInstances); } catch (ObjectCollectedExceptionWrapper | VMDisconnectedExceptionWrapper | InternalExceptionWrapper ex) { return Collections.emptyList(); } return new AbstractList<ObjectVariable>() { @Override public ObjectVariable get(int i) { ObjectReference obj = instances.get(i); return new AbstractObjectVariable(debugger, obj, classType.name()+" instance "+i); } @Override public int size() { return instances.size(); } }; }
private static Iterable<Object> iterable( final Object first, final Object second, final Object[] rest) { checkNotNull(rest); return new AbstractList<Object>() { @Override public int size() { return rest.length + 2; } @Override public Object get(int index) { switch (index) { case 0: return first; case 1: return second; default: return rest[index - 2]; } } }; }
/** * Convert the internal {@link List} of values back to a user-friendly list. * Integers are kept as-is since the terms query does not make any difference * between {@link Integer}s and {@link Long}s, but {@link BytesRef}s are * converted back to {@link String}s. */ static List<Object> convertBack(List<?> list) { return new AbstractList<Object>() { @Override public int size() { return list.size(); } @Override public Object get(int index) { Object o = list.get(index); if (o instanceof BytesRef) { o = ((BytesRef) o).utf8ToString(); } // we do not convert longs, all integer types are equivalent // as far as this query is concerned return o; } }; }
@GwtIncompatible // invokeAccessibleNonThrowingMethod private static List<StackTraceElement> jlaStackTrace(final Throwable t) { checkNotNull(t); /* * TODO(cpovirk): Consider optimizing iterator() to catch IOOBE instead of doing bounds checks. * * TODO(cpovirk): Consider the UnsignedBytes pattern if it performs faster and doesn't cause * AOSP grief. */ return new AbstractList<StackTraceElement>() { @Override public StackTraceElement get(int n) { return (StackTraceElement) invokeAccessibleNonThrowingMethod(getStackTraceElementMethod, jla, t, n); } @Override public int size() { return (Integer) invokeAccessibleNonThrowingMethod(getStackTraceDepthMethod, jla, t); } }; }
public Test testsForAbstractList() { return ListTestSuiteBuilder.using( new TestStringListGenerator() { @Override protected List<String> create(final String[] elements) { return new AbstractList<String>() { @Override public int size() { return elements.length; } @Override public String get(int index) { return elements[index]; } }; } }) .named("AbstractList") .withFeatures( CollectionFeature.NONE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionSize.ANY) .suppressing(suppressForAbstractList()) .createTestSuite(); }
public void testAddAll_largeList() { final List<String> list = ImmutableList.of("one", "two", "three", "four", "five"); List<String> misbehavingList = new AbstractList<String>() { @Override public int size() { return list.size(); } @Override public String get(int index) { if (index < 2) { throw new AssertionError(); } return list.get(index); } }; EvictingQueue<String> queue = EvictingQueue.create(3); assertTrue(queue.addAll(misbehavingList)); assertEquals("three", queue.remove()); assertEquals("four", queue.remove()); assertEquals("five", queue.remove()); assertTrue(queue.isEmpty()); }
public List<Long> getAllObjKeys() { return new AbstractList<Long>() { @Override public Long get(int index) { if (index == 0) { return primaryObjKey; } return fallBackObjKeys.get(index - 1); } @Override public Spliterator<Long> spliterator() { return super.spliterator(); } @Override public int size() { return fallBackObjKeys.size() + 1; } }; }
/** * {@inheritDoc} * * @see kodkod.engine.bool.Int#twosComplementBits() */ @Override public final List<BooleanValue> twosComplementBits() { return new AbstractList<BooleanValue>() { @Override public BooleanValue get(int i) { if (i < 0 || i >= factory.bitwidth) throw new IndexOutOfBoundsException(); return bit(i); } @Override public int size() { return factory.bitwidth; } }; }
/** * Report errors for unused propOrder entries. */ public void checkUnusedProperties() { for( int i=0; i<used.length; i++ ) if(used[i]==null) { String unusedName = propOrder[i]; String nearest = EditDistance.findNearest(unusedName, new AbstractList<String>() { public String get(int index) { return properties.get(index).getName(); } public int size() { return properties.size(); } }); boolean isOverriding = (i > (properties.size()-1)) ? false : properties.get(i).hasAnnotation(OverrideAnnotationOf.class); if (!isOverriding) { builder.reportError(new IllegalAnnotationException( Messages.PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY.format(unusedName,nearest),ClassInfoImpl.this)); } } }
/** * Return all the header lines as a collection * * @return list of header lines. */ public List<String> getAllHeaderLines() { if (headerValueView == null) headerValueView = new AbstractList<String>() { @Override public String get(int index) { return headers.get(index).line; } @Override public int size() { return headers.size(); } }; return headerValueView; }
/** * Populates this list with all prefix strings of a given string. All * of the prefix strings share the same backing array of chars. */ private synchronized void populate(int newSize) { final int size = size(); if (newSize <= size) { return; } final char[] chars = new char[newSize]; Arrays.fill(chars, ' '); final int length = newSize - size; final int offset = size; // addAll is much more efficient than repeated add for // CopyOnWriteArrayList addAll( new AbstractList<String>() { public String get(int index) { return new String(chars, 0, offset + index); } public int size() { return length; } }); }
/** * Returns a {@link List List<Integer>} representation of an primitive int array. * @param values the primitive int array to represent. * @return never code {@code null}. The returned list will be unmodifiable yet it will reflect changes in values in the original array yet * you cannot change the values */ public static List<Integer> asList(final int ... values) { if (values == null) throw new IllegalArgumentException("the input array cannot be null"); return new AbstractList<Integer>() { @Override public Integer get(final int index) { return values[index]; } @Override public int size() { return values.length; } }; }
/** * Returns a {@link List List<Double>} representation of an primitive double array. * @param values the primitive int array to represent. * @return never code {@code null}. The returned list will be unmodifiable yet it will reflect changes in values in the original array yet * you cannot change the values. */ public static List<Double> asList(final double ... values) { if (values == null) throw new IllegalArgumentException("the input array cannot be null"); return new AbstractList<Double>() { @Override public Double get(final int index) { return values[index]; } @Override public int size() { return values.length; } }; }
@Nonnull @Override public List<? extends MethodParameter> getParameters() { final Constructor method = this.constructor; return new AbstractList<MethodParameter>() { private final Class[] parameters = method.getParameterTypes(); @Override public MethodParameter get(final int index) { return new BaseMethodParameter() { @Nonnull @Override public Set<? extends Annotation> getAnnotations() { return ImmutableSet.of(); } @Nullable @Override public String getName() { return null; } @Nonnull @Override public String getType() { return ReflectionUtils.javaToDexName(parameters[index].getName()); } }; } @Override public int size() { return parameters.length; } }; }
@Nonnull @Override public List<? extends MethodParameter> getParameters() { final java.lang.reflect.Method method = this.method; return new AbstractList<MethodParameter>() { private final Class[] parameters = method.getParameterTypes(); @Override public MethodParameter get(final int index) { return new BaseMethodParameter() { @Nonnull @Override public Set<? extends Annotation> getAnnotations() { return ImmutableSet.of(); } @Nullable @Override public String getName() { return null; } @Nonnull @Override public String getType() { return ReflectionUtils.javaToDexName(parameters[index].getName()); } }; } @Override public int size() { return parameters.length; } }; }
/** * This overload is like the above, but uses reflection to operate on any * primitive or object type. */ public static <T> WritableNativeArray makeNativeArray(final Object objects) { if (objects == null) { return new WritableNativeArray(); } // No explicit check for objects's type here. If it's not an array, the // Array methods will throw IllegalArgumentException. return makeNativeArray(new AbstractList() { public int size() { return Array.getLength(objects); } public Object get(int index) { return Array.get(objects, index); } }); }
/** * Get the key list. The list is a read-only representation of all keys. * <p> * The get and indexOf methods are O(log(size)) operations. The result of * indexOf is cast to an int. * * @return the key list */ public List<K> keyList() { return new AbstractList<K>() { @Override public K get(int index) { return getKey(index); } @Override public int size() { return MVMap.this.size(); } @Override @SuppressWarnings("unchecked") public int indexOf(Object key) { return (int) getKeyIndex((K) key); } }; }
/** * @return a live List of selected model items. */ public List selectedModelItems() { return new AbstractList() { public Object get(int index) { MysteryComponent component = (MysteryComponent) selectedMysteryComponents.get(index); return component.getModel(); } public int size() { return selectedMysteryComponents.size(); } }; }
@Test public void testExtends() { try { final XExpression expression = this.expression("null", false); final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> { it.setAbstract(true); EList<JvmTypeReference> _superTypes = it.getSuperTypes(); JvmTypeReference _typeRef = this.typeRef(expression, AbstractList.class, String.class); this.builder.<JvmTypeReference>operator_add(_superTypes, _typeRef); }; final JvmGenericType clazz = this.builder.toClass(expression, "my.test.Foo", _function); final Class<?> compiled = this.compile(expression.eResource(), clazz); Assert.assertTrue(Iterable.class.isAssignableFrom(compiled)); Assert.assertTrue(AbstractList.class.isAssignableFrom(compiled)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testAnonymousClass() { List<String> list = new AbstractList<String>() { @Override public int size() { return 0; } @Override public String get(int i) { return null; } }; // we call clear here to drop the messages generated by the test method itself InMemoryTracerProvider.INSTANCE.getTracer().clearMessages(); list.size(); MessageSequenceAsserter.messageSequence() .entering("size") .returning("size", 0) .exiting("size"); }
@Test @SuppressWarnings("null") public void testSuperClass() { final Class<?>[][] classes = { {Object.class, Object.class}, {String.class, String.class}, {String.class, Object.class, Object.class}, {Object.class, String.class, Object.class}, {String.class, String.class, String.class}, {Object.class, String.class, Object.class, String.class, Object.class}, {Double.class, Integer.class, Number.class}, {UnknownHostException.class, FileNotFoundException.class, IOException.class}, {SortedMap.class, TreeMap.class, SortedMap.class}, {LinkedList.class, ArrayList.class, AbstractList.class}, {List.class, Set.class, Collection.class}, {ArrayList.class, Set.class, Collection.class}, }; for (final Class<?>[] cs : classes) { assertEquals(cs[cs.length - 1], Utils.getSuperType(Arrays.copyOf(cs, cs.length - 1))); } }
public List<CadObject> getOwnedObjects() { return new AbstractList<CadObject>() { @Override public CadObject get(int index) { CadObject result = objectMap.parseObject(ownedObjectHandles[index]); return result; } @Override public int size() { return ownedObjectHandles.length; } }; }
public List<CadObject> getViewPorts() { return new AbstractList<CadObject>() { @Override public CadObject get(int index) { CadObject result = objectMap.parseObject(viewportHandles[index]); if (!(result instanceof VPort || result instanceof ViewPort)) { throw new RuntimeException("unexpected object class"); } return (CadObject) result; } @Override public int size() { return viewportHandles.length; } }; }
public List<LType> getLineTypes() { return new AbstractList<LType>() { @Override public LType get(int index) { return (LType)objectMap.parseObjectPossiblyNull(lineTypeHandles[index]); } @Override public int size() { return lineTypeHandles.length; } }; }