Inspection Gadgets problem

Hi!

IG plugin says

Name:
public method Tag get(int i)

Location:
TagPack (ru.sterling.io3.tag)

Problem synopsis:
Cast to concrete class Tag at line 37

In such code

public synchronized Tag get(int i)
{
return (Tag)list.get(i);
}

Is it right?

___
/** WBR @author Denis Tsyplakov @ICQ_UIN 108477017
@mailto: lc@yandex.ru */


4 comments
Comment actions Permalink

It is correct if Tag is neither an Interface nor an Abstract Class.

"Denis Tsyplakov" <Tsyplakov_Denis_Y@sterling.ru> wrote in message
news:c7ddg9$cej$1@is.intellij.net...

Hi!

>

IG plugin says

>

Name:
public method Tag get(int i)

>

Location:
TagPack (ru.sterling.io3.tag)

>

Problem synopsis:
Cast to concrete class Tag at line 37

>

In such code

>

public synchronized Tag get(int i)
{
return (Tag)list.get(i);
}

>

Is it right?

>

___
/** WBR @author Denis Tsyplakov @ICQ_UIN 108477017
@mailto: lc@yandex.ru */

>
>


0
Comment actions Permalink

Hi!

TH> It is correct if Tag is neither an Interface nor an Abstract Class.

Tag is abstract class

___
/** WBR @author Denis Tsyplakov @ICQ_UIN 108477017
@mailto: lc@yandex.ru */


0
Comment actions Permalink

Actually, this error return is correct unless Tag is an interface. Abstract classes will trigger this inspection. The purpose of this inspection is to encourage/enforce loose coupling via interface- or component-based programming. If that's not what you're doing, this inspection is not for you. I'll see if I can brush up the documentation to reflect this.

--Dave Griffith

0
Comment actions Permalink

Dave,

If an abstract class triggers this inspection, the the name of the
inspection is misleading.

Tim

"Dave Griffith" <dave.griffith@cnn.com> wrote in message
news:4281760.1083851228103.JavaMail.itn@is.intellij.net...

Actually, this error return is correct unless Tag is an interface.

Abstract classes will trigger this inspection. The purpose of this
inspection is to encourage/enforce loose coupling via interface- or
component-based programming. If that's not what you're doing, this
inspection is not for you. I'll see if I can brush up the documentation to
reflect this.
>

--Dave Griffith



0

Please sign in to leave a comment.