org.magicwerk.brownies.html.HtmlResource Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2010 by Thomas Mauch
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id$
*/
package org.magicwerk.brownies.html;
import org.magicwerk.brownies.core.ObjectHelper;
/**
* Class representing a resource which can be added to a HtmlDocument.
* A HtmlResource has a unique name which prevents them from being added more than once.
*
* @author Thomas Mauch
* @version $Id$
*/
public class HtmlResource {
String name;
HtmlHead head;
HtmlBlock body;
/**
* Create a HtmlResource with a unique name.
*
* @param name name
*/
public HtmlResource(String name) {
this.name = name;
head = new HtmlHead();
body = HtmlTools.createBody();
}
public String getName() {
return name;
}
/** Getter for {@link #head} */
public HtmlHead getHead() {
return head;
}
/** Setter for {@link #head} */
public HtmlResource setHead(HtmlHead head) {
this.head = head;
return this;
}
/** Getter for {@link #body} */
public HtmlBlock getBody() {
return body;
}
/** Setter for {@link #body} */
public HtmlResource setBody(HtmlBlock body) {
this.body = body;
return this;
}
@Override
public boolean equals(Object obj) {
return ObjectHelper.implEquals(this, obj, HtmlResource::getName);
}
@Override
public int hashCode() {
return ObjectHelper.implHashCode(this, HtmlResource::getName);
}
@Override
public String toString() {
return "HtmlResource: " + name;
}
}