Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

withLink() how to specify name/title/description? #35

Closed
jamesladd opened this issue Jun 19, 2012 · 5 comments
Closed

withLink() how to specify name/title/description? #35

jamesladd opened this issue Jun 19, 2012 · 5 comments

Comments

@jamesladd
Copy link

How do you specify the name/title or description attributes of a Link using the
withLink methods of the builder?

  • James.
@talios
Copy link
Owner

talios commented Jun 19, 2012

James,

On the Resource interface there is a "full" argument method:

https://github.com/talios/halbuilder/blob/develop/src/main/java/com/theoryinpractise/halbuilder/spi/Resource.java

Resource withLink(String href, String rel,
Optional<Predicate> predicate, Optional name,
Optional title, Optional hreflang);

This lets you add a name, title, lang and predicate as optionals. It's
not as pretty as I'd like but without real optional arguments I'd end up
with endless permutations.

Re: the last email - looks like I added the URI based variations of the
withLink methods awhile ago as additional overloaded methods.

On 19/06/12 5:04 PM, James Ladd wrote:

How do you specify the name/title or description attributes of a Link using the
withLink methods of the builder?

  • James.

Reply to this email directly or view it on GitHub:
#35

@jamesladd
Copy link
Author

Mark,

Im not sure how to call the method - do you have an example?

BTW - you could make the withLink method a var args when you get to the
optional elements, then assume they are specific args based on count and
position.

On Tue, Jun 19, 2012 at 3:39 PM, Mark Derricutt <
reply@reply.github.com

wrote:

James,

On the Resource interface there is a "full" argument method:

https://github.com/talios/halbuilder/blob/develop/src/main/java/com/theoryinpractise/halbuilder/spi/Resource.java

Resource withLink(String href, String rel,
Optional<Predicate> predicate, Optional name,
Optional title, Optional hreflang);

This lets you add a name, title, lang and predicate as optionals. It's
not as pretty as I'd like but without real optional arguments I'd end up
with endless permutations.

Re: the last email - looks like I added the URI based variations of the
withLink methods awhile ago as additional overloaded methods.

On 19/06/12 5:04 PM, James Ladd wrote:

How do you specify the name/title or description attributes of a Link
using the
withLink methods of the builder?

  • James.

Reply to this email directly or view it on GitHub:
#35


Reply to this email directly or view it on GitHub:
#35 (comment)

@talios
Copy link
Owner

talios commented Jun 19, 2012

On 19/06/12 5:46 PM, James Ladd wrote:

Mark,

Im not sure how to call the method - do you have an example?

The Optional class is from Google Guava and can be created via:

Optional.of(something) for a "this is not null" result or:
Optional.fromNullable(somethingThatMayBeNull) which will return an
absent Optional if null, or finally:
Optional.absent() for an optional that dosn't exist.

The vararg idea is interesting, I have an idea of doing that in a nice
position independent way as well.

@jamesladd
Copy link
Author

How do I do the predicate argument?

With the other attributes you could return builders for those too.
WithLink().withName() etc

  • James

Sent from a Mind Control Device

On 19/06/2012, at 7:20 PM, Mark Derricuttreply@reply.github.com wrote:

On 19/06/12 5:46 PM, James Ladd wrote:

Mark,

Im not sure how to call the method - do you have an example?

The Optional class is from Google Guava and can be created via:

Optional.of(something) for a "this is not null" result or:
Optional.fromNullable(somethingThatMayBeNull) which will return an
absent Optional if null, or finally:
Optional.absent() for an optional that dosn't exist.

The vararg idea is interesting, I have an idea of doing that in a nice
position independent way as well.


Reply to this email directly or view it on GitHub:
#35 (comment)

@talios
Copy link
Owner

talios commented Jun 19, 2012

Predicate is another Guava interface:

http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/Predicates.html

A Predicate has one method called apply(T t) which simply returns
true/false.

I'm using it in HalBuilder to provide a means of doing conditional
links.

On Tue Jun 19 21:42:28 2012, James Ladd wrote:

How do I do the predicate argument?

With the other attributes you could return builders for those too.
WithLink().withName() etc

  • James

Sent from a Mind Control Device

On 19/06/2012, at 7:20 PM, Mark Derricuttreply@reply.github.com wrote:

On 19/06/12 5:46 PM, James Ladd wrote:

Mark,

Im not sure how to call the method - do you have an example?

The Optional class is from Google Guava and can be created via:

Optional.of(something) for a "this is not null" result or:
Optional.fromNullable(somethingThatMayBeNull) which will return an
absent Optional if null, or finally:
Optional.absent() for an optional that dosn't exist.

The vararg idea is interesting, I have an idea of doing that in a nice
position independent way as well.


Reply to this email directly or view it on GitHub:
#35 (comment)


Reply to this email directly or view it on GitHub:
#35 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants