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

Unnecessary @SuppressWarnings java warnings after upgrade #498

Closed
lennylucas opened this issue Feb 2, 2016 · 4 comments · Fixed by #501
Closed

Unnecessary @SuppressWarnings java warnings after upgrade #498

lennylucas opened this issue Feb 2, 2016 · 4 comments · Fixed by #501
Assignees
Milestone

Comments

@lennylucas
Copy link

After upgrading to version 0.4.18 we've started receiving a load of Java warnings like so:

Unnecessary @SuppressWarnings("unchecked")

@joelittlejohn
Copy link
Owner

I think these are caused by the annotations added during the dynamic properties work. Could you give an example of the code block?

@joelittlejohn
Copy link
Owner

For reference, the see #386. Note, these dynamic properties will not be on by default in the next release.

In the meantime, if you want to suppress this code entirely, you can set includeDynamicAccessors to false.

@lennylucas
Copy link
Author

Thanks Joe. Will look at that property. Example code below.

    @SuppressWarnings({
        "unchecked"
    })
    protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) {
        switch (name) {
            case "paf":
                return getPaf();
            case "address_base":
                return getAddressBase();
            default:
                return notFoundValue;
        }
    }

    @SuppressWarnings({
        "unchecked"
    })
    public<T >T get(String name) {
        Object value = declaredPropertyOrNotFound(name, AdditionalIds.NOT_FOUND_VALUE);
        if (AdditionalIds.NOT_FOUND_VALUE!= value) {
            return ((T) value);
        } else {
            throw new IllegalArgumentException((("property \""+ name)+"\" is not defined"));
        }
    }

    @SuppressWarnings({
        "unchecked"
    })
    public void set(String name, Object value) {
        if (!declaredProperty(name, value)) {
            throw new IllegalArgumentException((("property \""+ name)+"\" is not defined"));
        }
    }

    @SuppressWarnings({
        "unchecked"
    })
    public AdditionalIds with(String name, Object value) {
        if (!declaredProperty(name, value)) {
            throw new IllegalArgumentException((("property \""+ name)+"\" is not defined"));
        }
        return this;
    }

@ctrimble
Copy link
Collaborator

ctrimble commented Feb 2, 2016

Those are definitely caused by that include dynamic accessors feature. I will see about moving them from the method signatures to the call sites. That should make them only present when casting happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants