Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365283 - Quickfix to unneccessary code / non-static class property
Summary: Quickfix to unneccessary code / non-static class property
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.4 M7   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-01 04:17 EST by Peter CLA
Modified: 2014-04-29 02:41 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter CLA 2011-12-01 04:17:26 EST
Build Identifier: 

If an class contains nonstatic subclasses, the subclass can only instanticated  from classinstances only (i.e. factory-creational-pattern GoF). Often those subclasses requires params from the class.

Sometimes users pass those values to the subclass via constructor-parameter, instead of pass those values directly to the subclassfield. 

Reproducible: Always

Steps to Reproduce:
public class TeaFactory{
  String factoryFlavour="Earl Grey";
  public class Teabag{
    public final String flavour;
    Teabag(String factoryFlavour){
      this.flavour = factoryFlavour;
    }
  }
  public TeabagNEW{
    public final String flavour = factoryFlavour;
  }
  public Teabag produceTeabag(){
    return new Teabag(factoryFlavour);
  }
}
Comment 1 Ayushman Jain CLA 2011-12-01 10:20:35 EST
Can you please give a valid code snippet? The above snippet is invalid because of "public TeabagNEW{".
Also, please clearly mention what error are you asking a quick fix for.
Comment 2 Peter CLA 2014-04-10 04:36:35 EDT
No, sorry.
Comment 3 Manoj N Palat CLA 2014-04-29 02:41:07 EDT
Verified as invalid for Eclipse Luna 4.4 M7 Build id: I20140428-2000