/** * Creates a new title object, containing the title of the specified object. */ public TitleBuffer(final Object object) { this(); concat(object); }
/** * Creates a new title object, containing the specified text. */ public TitleBuffer(final String text) { this(); concat(text); }
/** * Creates a new title object, containing the specified text. */ public TitleBuffer(final String text) { this(); concat(text); }
/** * Concatenate the the title value (the result of calling an objects label() * method) to this TitleString object. If the value is null the no text is * added. * * @param object * the ObjectAdapter to get a title from * @return a reference to the called object (itself). */ public final TitleBuffer concat(final Object object) { concat(object, ""); return this; }
/** * Concatenate the the title value (the result of calling an objects label() * method) to this TitleString object. If the value is null the no text is * added. * * @param object * the ObjectAdapter to get a title from * @return a reference to the called object (itself). */ public final TitleBuffer concat(final Object object) { concat(object, ""); return this; }
/** * Creates a new {@link org.apache.isis.applib.util.TitleBuffer}, containing the title of the specified object. * * <p> * Note: this method only obtains the title using either <tt>title()</tt> or <tt>toString()</tt>; it doesn't * honour other mechanisms for specifying the title, such as {@link org.apache.isis.applib.annotation.Title} * annotation. If that functionality is required, first call * {@link org.apache.isis.applib.DomainObjectContainer#titleOf(Object)} on the object and pass in the resultant * string. * </p> */ public TitleBuffer(final Object object) { this(); concat(object); }
/** * Creates a new title object, containing the title of the specified object. * * <p> * Note: this method only obtains the title using either <tt>title()</tt> or <tt>toString()</tt>; it doesn't * honour other mechanisms for specifying the title, such as {@link org.apache.isis.applib.annotation.Title} * annotation. If that functionality is required, first call * {@link org.apache.isis.applib.DomainObjectContainer#titleOf(Object)} on the object and pass in the resultant * string. * </p> */ public TitleBuffer(final Object object, final String defaultTitle) { this(); String title = titleFor(object); if (isEmpty(title)) { concat(defaultTitle); } else { concat(title); } }
/** * Concatenate the joiner text and the title of the object to the text of * this TitleString object. If no object yet exists in the object then the * joiner text is omitted. * * @return a reference to the called object (itself). */ public final TitleBuffer concat(final String joiner, final Object object) { if (!isEmpty(object)) { appendJoiner(joiner); concat(object, ""); } return this; }
@Test public void testConcatObjectsWhereDefaultNotNeededAddsTitle() { t1.concat(objectWithTitle, "none"); assertEquals(name + companyName, t1.toString()); }
@Test public void testConcatObjects() { t1.concat(objectWithTitle); assertEquals(name + companyName, t1.toString()); }
/** * Concatenate the joiner text and the title of the object to the text of * this {@link org.apache.isis.applib.util.TitleBuffer}. If no object yet exists in the object then the * joiner text is omitted. * * <p> * Note: this method only obtains the title using either <tt>title()</tt> or <tt>toString()</tt>; it doesn't * honour other mechanisms for specifying the title, such as {@link org.apache.isis.applib.annotation.Title} * annotation. If that functionality is required, first call * {@link org.apache.isis.applib.DomainObjectContainer#titleOf(Object)} on the object and pass in the resultant * string. * </p> * * @return a reference to the called object (itself). */ public final TitleBuffer concat(final String joiner, final Object object) { String title = titleFor(object); if (!isEmpty(title)) { appendJoiner(joiner); concat(title, ""); } return this; }
@Test public void testConcatObjectsWhereNoTitleAddDefaultTitle() { t1.concat(objectWithNoTitle, "none"); assertEquals(name + "none", t1.toString()); }
@Test public void testConcatEmptyStringLeavesBufferUnchanged() { t1.concat(""); assertEquals(name, t1.toString()); }
@Test public void testConcatObjectWhereNoTitleLeavesBufferUnchanged() { t1.concat(objectWithNoTitle); assertEquals(name, t1.toString()); }
@Test public void testConcatObjectWhereTitleIsAdded() { t1.concat(objectWithTitle); assertEquals("FredABC Co.", t1.toString()); }
@Test public void testConcatStringAddsString() { t1.concat("Smith"); assertEquals("FredSmith", t1.toString()); }