/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
/** * Get attribute value, stored on the {@link AttributeStorage}, * the difference from {@link #get(AttributeStorage)} is * that default value or {@link NullaryFunction} won't be invoked. * * @param storage {@link AttributeStorage}. * @return attribute value */ public T peek(final AttributeStorage storage) { final AttributeHolder holder = storage.getAttributes(); if (holder != null) { return peek(holder); } return null; }
@Test public void testAttributeGetWithNullaryFunctionOnEmptyHolder() { AttributeBuilder builder = new DefaultAttributeBuilder(); AttributeHolder holder = isSafe ? builder.createSafeAttributeHolder() : builder.createUnsafeAttributeHolder(); final Attribute<String> attr = builder.createAttribute( "attribute", new NullaryFunction<String>() { @Override public String evaluate() { return "default"; } } ); assertNull(attr.peek(holder)); assertEquals("default", attr.get(holder)); assertTrue(attr.isSet(holder)); assertEquals("default", attr.peek(holder)); }
@Test public void testAttributeGetWithoutInitializerOnEmptyHolder() { AttributeBuilder builder = new DefaultAttributeBuilder(); AttributeHolder holder = isSafe ? builder.createSafeAttributeHolder() : builder.createUnsafeAttributeHolder(); final Attribute<String> attr = builder.createAttribute("attribute"); assertNull(attr.peek(holder)); assertEquals(null, attr.get(holder)); assertFalse(attr.isSet(holder)); } }