File . java without class signature

Asked

Viewed 44 times

2

I was taking a look at primefaces code, when I came across the following situation (buttontemplate.java file):

import java.util.List;
import java.util.Map;
import org.primefaces.util.HTML;
import java.util.logging.Logger;
import org.primefaces.util.ComponentUtils;

    private final static Logger logger = Logger.getLogger(Button.class.getName());

    public String resolveIcon() {
        String icon = getIcon();

        if(icon == null) {
            icon = getImage();

            if(icon != null)
                logger.info("image attribute is deprecated to define an icon, use icon attribute instead.");
        }

        return icon;
    }

    public String resolveStyleClass() {
        String icon = resolveIcon();
        Object value = getValue();
        String styleClass = ""; 

        if(value != null && ComponentUtils.isValueBlank(icon)) {
            styleClass = HTML.BUTTON_TEXT_ONLY_BUTTON_CLASS;
        }
        else if(value != null && !ComponentUtils.isValueBlank(icon)) {
            styleClass = getIconPos().equals("left") ? HTML.BUTTON_TEXT_ICON_LEFT_BUTTON_CLASS : HTML.BUTTON_TEXT_ICON_RIGHT_BUTTON_CLASS;
        }
        else if(value == null && !ComponentUtils.isValueBlank(icon)) {
            styleClass = HTML.BUTTON_ICON_ONLY_BUTTON_CLASS;
        }

        if(isDisabled()) {
            styleClass = styleClass + " ui-state-disabled";
        } 

        String userStyleClass = getStyleClass();
        if(userStyleClass != null) {
            styleClass = styleClass + " " + userStyleClass;
        }

        return styleClass;
    }

    public Map<String, List<String>> getParams() {
        return ComponentUtils.getUIParams(this);
    }

In this file there is no "declaration" of a class (e.g.: public class ButtonTemplate { }).

  • What is this?

  • How it works?

  • Has "template" in the name, should be called in another class with correct signature.

  • Is that a "class composition"? @Articuno

  • In this case, it is not a class template, but a code template itself. Java cannot do much with what has been provided, so the programmer must fill in the gaps. This repeats throughout the directory java-template

  • @Jefferasked how it works?

  • You copy, paste, fill in the code gaps. Like the class declaration, the lock class keys, package declaration etc

  • It seems to me to be some case where he copies and pastes the code around and then changes it to do something.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.