Skip to content

Throws Exception on certain method #3

@RoRoche

Description

@RoRoche

Currently, Java-NoOp generates methods with default data type values.

On some case, it could be interesting to throw an exception to notify that it's a no-op object and it's not going to provide a valid behavior.

For example, here is an Employee interface:

@NoOp
public interface Employee {
    String name();

    void doCriticalStuff();
}

Dealing with a NoOpEmployee, there's no problem to get a empty name.
But on my doCriticalStuff, it would be nice to throw a specific exception.
For example, this could be the Employee interface:

@NoOp
public interface Employee {
    String name();

    @NoOpThrows(class=NoOpException.class, message="It's a no-op object, critical stuff can't be done properly")
    void doCriticalStuff();
}

generating:

public class NoOpEmployee implements Employee {
    // ...

    @Override
    public void doCriticalStuff() {
        throw new NoOpException("It's a no-op object, critical stuff can't be done properly");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions