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

Complete null annotations in API #32

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/main/java/io/wcm/handler/media/Media.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void setMediaRequest(@NotNull MediaRequest mediaRequest) {
* @return Html element
*/
@JsonIgnore
public HtmlElement<?> getElement() {
public @Nullable HtmlElement<?> getElement() {
if (this.element == null && this.elementBuilder != null) {
this.element = this.elementBuilder.apply(this);
this.elementBuilder = null;
Expand All @@ -109,7 +109,7 @@ public HtmlElement<?> getElement() {
* @return Media HTML element serialized to string. Returns null if media element is null.
*/
@JsonIgnore
public String getMarkup() {
public @Nullable String getMarkup() {
HtmlElement<?> el = getElement();
if (markup == null && el != null) {
if (el instanceof Span) {
Expand All @@ -130,38 +130,38 @@ public String getMarkup() {
/**
* @param value Function that builds the HTML element representation on demand
*/
public void setElementBuilder(Function<Media, HtmlElement<?>> value) {
public void setElementBuilder(@NotNull Function<Media, HtmlElement<?>> value) {
this.elementBuilder = value;
this.markup = null;
}

/**
* @return Media URL
*/
public String getUrl() {
public @Nullable String getUrl() {
return this.url;
}

/**
* @param value Media URL
*/
public void setUrl(String value) {
public void setUrl(@Nullable String value) {
this.url = value;
}

/**
* Get media item info that was resolved during media handler processing
* @return Media item
*/
public Asset getAsset() {
public @Nullable Asset getAsset() {
return this.asset;
}

/**
* Set media item that was resolved during media handler processing
* @param asset Media item
*/
public void setAsset(Asset asset) {
public void setAsset(@Nullable Asset asset) {
this.asset = asset;
}

Expand All @@ -170,7 +170,7 @@ public void setAsset(Asset asset) {
* @return Rendition
*/
@JsonIgnore
public Rendition getRendition() {
public @Nullable Rendition getRendition() {
if (this.renditions == null || this.renditions.isEmpty()) {
return null;
}
Expand All @@ -181,7 +181,7 @@ public Rendition getRendition() {
* Get all renditions that were resolved during media handler processing
* @return Renditions
*/
public Collection<Rendition> getRenditions() {
public @NotNull Collection<Rendition> getRenditions() {
if (this.renditions == null) {
return Collections.emptyList();
}
Expand All @@ -194,7 +194,7 @@ public Collection<Rendition> getRenditions() {
* Set all renditions that was resolved during media handler processing
* @param renditions Renditions
*/
public void setRenditions(Collection<Rendition> renditions) {
public void setRenditions(@Nullable Collection<Rendition> renditions) {
this.renditions = renditions;
}

Expand Down Expand Up @@ -254,30 +254,30 @@ public boolean isValid() {
* @return Reason why the requested media could not be resolved and is invalid
*/
@JsonIgnore
public MediaInvalidReason getMediaInvalidReason() {
public @Nullable MediaInvalidReason getMediaInvalidReason() {
return this.mediaInvalidReason;
}

/**
* @param mediaInvalidReason Reason why the requested media could not be resolved and is invalid
*/
public void setMediaInvalidReason(MediaInvalidReason mediaInvalidReason) {
public void setMediaInvalidReason(@Nullable MediaInvalidReason mediaInvalidReason) {
this.mediaInvalidReason = mediaInvalidReason;
}

/**
* @return Custom message when {@link #getMediaInvalidReason()} is set to {@link MediaInvalidReason#CUSTOM}.
* Message is interpreted as i18n key.
*/
public String getMediaInvalidReasonCustomMessage() {
public @Nullable String getMediaInvalidReasonCustomMessage() {
return this.mediaInvalidReasonCustomMessage;
}

/**
* @param mediaInvalidReasonCustomMessage Custom message when {@link #getMediaInvalidReason()} is set to
* {@link MediaInvalidReason#CUSTOM}. Message is interpreted as i18n key.
*/
public void setMediaInvalidReasonCustomMessage(String mediaInvalidReasonCustomMessage) {
public void setMediaInvalidReasonCustomMessage(@Nullable String mediaInvalidReasonCustomMessage) {
this.mediaInvalidReasonCustomMessage = mediaInvalidReasonCustomMessage;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ else if (mediaFormatsMandatory.length > i) {
/**
* @return Image sizes
*/
@SuppressWarnings("null")
public @Nullable ImageSizes getImageSizes() {
String responsiveType = getResponsiveType();
if (responsiveType != null && !StringUtils.equals(responsiveType, RESPONSIVE_TYPE_IMAGE_SIZES)) {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/io/wcm/handler/media/MediaHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public interface MediaHandler {
* @return Media builder
*/
@NotNull
MediaBuilder get(Resource resource);
MediaBuilder get(@Nullable Resource resource);

/**
* Build media which is referenced in the resource (as property or inline binary data).
Expand All @@ -57,7 +57,7 @@ public interface MediaHandler {
* @return Media builder
*/
@NotNull
MediaBuilder get(Resource resource, MediaArgs mediaArgs);
MediaBuilder get(@Nullable Resource resource, @NotNull MediaArgs mediaArgs);

/**
* Build media which is referenced in the resource (as property or inline binary data).
Expand All @@ -68,7 +68,7 @@ public interface MediaHandler {
* @return Media builder
*/
@NotNull
MediaBuilder get(Resource resource, MediaFormat... mediaFormats);
MediaBuilder get(@Nullable Resource resource, MediaFormat @NotNull... mediaFormats);

/**
* Build media which is referenced via its string address.
Expand All @@ -78,7 +78,7 @@ public interface MediaHandler {
* @see #get(String, Resource)
*/
@NotNull
MediaBuilder get(String mediaRef);
MediaBuilder get(@Nullable String mediaRef);

/**
* Build media which is referenced via its string address.
Expand All @@ -88,7 +88,7 @@ public interface MediaHandler {
* @return Media builder
*/
@NotNull
MediaBuilder get(String mediaRef, @Nullable Resource contextResource);
MediaBuilder get(@Nullable String mediaRef, @Nullable Resource contextResource);

/**
* Build media which is referenced via its string address.
Expand All @@ -97,7 +97,7 @@ public interface MediaHandler {
* @return Media builder
*/
@NotNull
MediaBuilder get(String mediaRef, MediaArgs mediaArgs);
MediaBuilder get(@Nullable String mediaRef, @NotNull MediaArgs mediaArgs);

/**
* Build media which is referenced via its string address.
Expand All @@ -106,7 +106,7 @@ public interface MediaHandler {
* @return Media builder
*/
@NotNull
MediaBuilder get(String mediaRef, MediaFormat... mediaFormats);
MediaBuilder get(@Nullable String mediaRef, MediaFormat @NotNull... mediaFormats);

/**
* Build media for the given request holding all further request properties.
Expand All @@ -122,7 +122,7 @@ public interface MediaHandler {
* @param element Media markup element.
* @return true if media element is invalid
*/
boolean isValidElement(HtmlElement<?> element);
boolean isValidElement(@Nullable HtmlElement<?> element);

/**
* Returns an empty media that is marked as invalid.
Expand Down
Loading