Skip to content

Commit beeb2ac

Browse files
committed
Explicitly support and use @repeatable from Java 8
1 parent ebec929 commit beeb2ac

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

headertags-demo/src/main/java/org/vaadin/leif/headertags/demo/DemoUI.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import org.vaadin.leif.headertags.Link;
66
import org.vaadin.leif.headertags.Meta;
7-
import org.vaadin.leif.headertags.MetaTags;
87
import org.vaadin.leif.headertags.Viewport;
98
import org.vaadin.leif.headertags.ViewportGenerator;
109

@@ -17,10 +16,9 @@
1716
// Sets a basic viewport meta header
1817
@Viewport("width=device-width, initial-scale=1")
1918
// Adds multiple tags of the same type
20-
@MetaTags({
21-
// Replaces the Vaadin X-UA-Compatible header
22-
@Meta(httpEquiv = "X-UA-Compatible", content = "hello"),
23-
@Meta(name = "test", content = "test") })
19+
// Replaces the Vaadin X-UA-Compatible header
20+
@Meta(httpEquiv = "X-UA-Compatible", content = "hello")
21+
@Meta(name = "test", content = "test")
2422
// And showing how to create a link tag as well
2523
@Link(rel = "foobar", href = "about:blank")
2624
public class DemoUI extends UI {

headertags/src/main/java/org/vaadin/leif/headertags/HeadTag.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.lang.annotation.Documented;
44
import java.lang.annotation.ElementType;
5+
import java.lang.annotation.Repeatable;
56
import java.lang.annotation.Retention;
67
import java.lang.annotation.RetentionPolicy;
78
import java.lang.annotation.Target;
@@ -34,8 +35,11 @@
3435
* <p>
3536
* Support for multiple annotations of the same type can also be used by
3637
* defining a collection annotation where value() returns an array of compatible
37-
* annotations. See {@link MetaTags} for an example of this usage.
38-
*
38+
* annotations. See {@link MetaTags} for an example of this usage. It's also
39+
* recommended to add {@link Repeatable} to the main annotation to enable
40+
* directly adding multiple similar annotation to a UI instead of using the
41+
* collection annotation.
42+
*
3943
* @see Meta
4044
* @see Viewport
4145
*/
@@ -46,7 +50,7 @@
4650
public @interface HeadTag {
4751
/**
4852
* The tag name to use for for annotations annotated with this type.
49-
*
53+
*
5054
* @return the HTML tag name
5155
*/
5256
public String value();

headertags/src/main/java/org/vaadin/leif/headertags/Link.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.lang.annotation.Documented;
44
import java.lang.annotation.ElementType;
55
import java.lang.annotation.Inherited;
6+
import java.lang.annotation.Repeatable;
67
import java.lang.annotation.Retention;
78
import java.lang.annotation.RetentionPolicy;
89
import java.lang.annotation.Target;
@@ -17,45 +18,46 @@
1718
@Target(ElementType.TYPE)
1819
@Documented
1920
@Inherited
21+
@Repeatable(LinkTags.class)
2022
public @interface Link {
2123
/**
2224
* The rel attribute value of the meta tag
23-
*
25+
*
2426
* @return the rel attribute
2527
*/
2628
public String rel();
2729

2830
/**
2931
* The href attribute value of the meta tag
30-
*
32+
*
3133
* @return the href attribute
3234
*/
3335
public String href();
3436

3537
/**
3638
* The media attribute value of the meta tag
37-
*
39+
*
3840
* @return the media attribute
3941
*/
4042
public String media() default HeadTag.NULL_VALUE;
4143

4244
/**
4345
* The type attribute value of the meta tag
44-
*
46+
*
4547
* @return the type attribute
4648
*/
4749
public String type() default HeadTag.NULL_VALUE;
4850

4951
/**
5052
* The sizes attribute value of the meta tag
51-
*
53+
*
5254
* @return the sizes attribute
5355
*/
5456
public String sizes() default HeadTag.NULL_VALUE;
5557

5658
/**
5759
* The sizes attribute value of the meta tag
58-
*
60+
*
5961
* @return the sizes attribute
6062
*/
6163
public String title() default HeadTag.NULL_VALUE;

headertags/src/main/java/org/vaadin/leif/headertags/Meta.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,52 @@
33
import java.lang.annotation.Documented;
44
import java.lang.annotation.ElementType;
55
import java.lang.annotation.Inherited;
6+
import java.lang.annotation.Repeatable;
67
import java.lang.annotation.Retention;
78
import java.lang.annotation.RetentionPolicy;
89
import java.lang.annotation.Target;
910

1011
/**
1112
* Defines an arbitrary &lt;meta&gt; tag for the host page of a UI class.
12-
* <p>
13-
* To add multiple tags, use {@link MetaTags}
1413
*/
1514
@HeadTag("meta")
1615
@Retention(RetentionPolicy.RUNTIME)
1716
@Target(ElementType.TYPE)
1817
@Documented
1918
@Inherited
19+
@Repeatable(MetaTags.class)
2020
public @interface Meta {
2121
/**
2222
* The name attribute value of the meta tag
23-
*
23+
*
2424
* @return the name attribute
2525
*/
2626
public String name() default HeadTag.NULL_VALUE;
2727

2828
/**
2929
* The content attribute value of the meta tag
30-
*
30+
*
3131
* @return the content attribute
3232
*/
3333
public String content() default HeadTag.NULL_VALUE;
3434

3535
/**
3636
* The http-equiv attribute value of the meta tag
37-
*
37+
*
3838
* @return the http-equiv attribute
3939
*/
4040
public String httpEquiv() default HeadTag.NULL_VALUE;
4141

4242
/**
4343
* The charset attribute value of the meta tag
44-
*
44+
*
4545
* @return the charset attribute
4646
*/
4747
public String charset() default HeadTag.NULL_VALUE;
4848

4949
/**
5050
* The itemprop attribute value of the meta tag
51-
*
51+
*
5252
* @return the itemprop attribute
5353
*/
5454
public String itemprop() default HeadTag.NULL_VALUE;

0 commit comments

Comments
 (0)