NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
Snirf
Joined: 03 Jul 2009 Posts: 3
|
Posted: Tue Aug 18, 2009 9:42 am Post subject: Autocompletion for all attributes |
|
|
Hi there,
i have a question about auto completion.
Let's say there is a class
| Code: |
public class MyClass implements java.io.Serializable {
public java.lang.Integer Id;
public java.lang.String Name;
public java.lang.String Reference;
public java.lang.String DefaultEmail;
public java.lang.String DefaultEmailNew;
public java.lang.Boolean SendReminder;
public java.math.BigDecimal VATRate;
.
.
.
}
|
and in my testclass i have to set all these attributes.
So i think it will be nice if i just type
| Code: |
MyClass myClass = new MyClass();
myClass.
|
and then netbeans will do an auto completion like
| Code: |
MyClass myClass = new MyClass();
myClass.Id = 0;
myClass.Name = null;
myClass.Reference = null;
myClass.DefaultEmail = null;
myClass.DefaultEmailNew = null;
myClass.SendReminder = false;
myClass.VATRate = 0;
|
Is there anywhere in netbeans a special command to do this?
Greets |
|
| Back to top |
|
 |
Melongo Annabel Posted via mailing list.
|
Posted: Wed Aug 19, 2009 12:38 am Post subject: Autocompletion for all attributes |
|
|
As far as I know, there isn't something like that. The only way to do that is to initialize your class object and to call that object in your code.
From: Snirf <address-removed>
To: address-removed
Sent: Tuesday, August 18, 2009 4:42:52 AM
Subject: [nbusers] Autocompletion for all attributes
Hi there,
i have a question about auto completion.
Let's say there is a class
Code:
public class MyClass implements java.io.Serializable {
public java.lang.Integer Id;
public java.lang.String Name;
public java.lang.String Reference;
public java.lang.String DefaultEmail;
public java.lang.String DefaultEmailNew;
public java.lang.Boolean SendReminder;
public java.math.BigDecimal VATRate;
.
.
.
}
and in my testclass i have to set all these attributes.
So i think it will be nice if i just type
Code:
MyClass myClass = new MyClass();
myClass.
and then netbeans will do an auto completion like
Code:
MyClass myClass = new MyClass();
myClass.Id = 0;
myClass.Name = null;
myClass.Reference = null;
myClass.DefaultEmail = null;
myClass.DefaultEmailNew = null;
myClass.SendReminder = false;
myClass.VATRate = 0;
Is there anywhere in netbeans a special command to do this?
Greets |
|
| Back to top |
|
 |
Mike Riley Posted via mailing list.
|
Posted: Wed Aug 19, 2009 12:59 am Post subject: Autocompletion for all attributes |
|
|
Doesn't Java already do that for you? When I am looking at a new instance
of a class in the debugger it shows uninitialized elements as 'null'. I was
assuming a newly allocated class had elements set to a value of 0, which
would give you numeric values of 0, a boolean of false, and objects which a
set to null.
For any non-zero values you would need to handle that in either a static
initializer method (for static values) or in your constructor method.
Or am I under a mis-conception as to how Java creates a new class instance?
Mike
Melongo Annabel wrote:
| Quote: | As far as I know, there isn't something like that. The only way to do
that is to initialize your class object and to call that object in your
code.
------------------------------------------------------------------------
*From:* Snirf <address-removed>
*To:* address-removed
*Sent:* Tuesday, August 18, 2009 4:42:52 AM
i have a question about auto completion.
Let's say there is a class
Code:
public class MyClass implements java.io <http://java.io.Se>.Serializable {
public java.lang.Integer Id;
public java.lang.String Name;
public java.lang.String Reference;
public java.lang.String DefaultEmail;
public java.lang.String DefaultEmailNew;
public java.lang.Boolean SendReminder;
public java.math.BigDecimal VATRate;
.
.
.
}
and in my testclass i have to set all these attributes.
So i think it will be nice if i just type
Code:
MyClass myClass = new MyClass();
myClass.
and then netbeans will do an auto completion like
Code:
MyClass myClass = new MyClass();
myClass.Id = 0;
myClass.Name = null;
myClass.Reference = null;
myClass.DefaultEmail = null;
myClass.DefaultEmailNew = null;
myClass.SendReminder = false;
myClass.VATRate = 0;
Is there anywhere in netbeans a special command to do this? |
|
|
| Back to top |
|
 |
Melongo Annabel Posted via mailing list.
|
Posted: Wed Aug 19, 2009 1:13 am Post subject: Autocompletion for all attributes |
|
|
Mike,
The issue is, you can't do that with code completion. It's something that has to be done inside your code.
From: Mike Riley <address-removed>
To: address-removed
Sent: Tuesday, August 18, 2009 7:59:07 PM
Subject: Re: [nbusers] Autocompletion for all attributes
Doesn't Java already do that for you? When I am looking at a new instance of a class in the debugger it shows uninitialized elements as 'null'. I was assuming a newly allocated class had elements set to a value of 0, which would give you numeric values of 0, a boolean of false, and objects which a set to null.
For any non-zero values you would need to handle that in either a static initializer method (for static values) or in your constructor method.
Or am I under a mis-conception as to how Java creates a new class instance?
Mike
Melongo Annabel wrote:
| Quote: | As far as I know, there isn't something like that. The only way to do that is to initialize your class object and to call that object in your code.
------------------------------------------------------------------------
*From:* Snirf <address-removed ([email]address-removed[/email])>
*To:* address-removed ([email]address-removed[/email])
*Sent:* Tuesday, August 18, 2009 4:42:52 AM
i have a question about auto completion.
Let's say there is a class
Code:
public class MyClass implements java.io <http://java.io.Se>.Serializable {
public java.lang.Integer Id;
public java.lang.String Name;
public java.lang.String Reference;
public java.lang.String DefaultEmail;
public java.lang.String DefaultEmailNew;
public java.lang.Boolean SendReminder;
public java.math.BigDecimal VATRate;
.
.
.
}
and in my testclass i have to set all these attributes.
So i think it will be nice if i just type
Code:
MyClass myClass = new MyClass();
myClass.
and then netbeans will do an auto completion like
Code:
MyClass myClass = new MyClass();
myClass.Id = 0;
myClass.Name = null;
myClass.Reference = null;
myClass.DefaultEmail = null;
myClass.DefaultEmailNew = null;
myClass.SendReminder = false;
myClass.VATRate = 0;
Is there anywhere in netbeans a special command to do this?
|
|
|
| Back to top |
|
 |
Mike Riley Posted via mailing list.
|
Posted: Wed Aug 19, 2009 1:21 am Post subject: Autocompletion for all attributes |
|
|
I agree. I was just asking if he really needed it, since his example was
simply wanting to set the various elements of the class to 0 or null. If
that is all he needed it seems his need for code completion does not really
exist.
Mike
Melongo Annabel wrote:
| Quote: | Mike,
The issue is, you can't do that with code completion. It's something
that has to be done inside your code.
------------------------------------------------------------------------
*From:* Mike Riley <address-removed>
*To:* address-removed
*Sent:* Tuesday, August 18, 2009 7:59:07 PM
*Subject:* Re: [nbusers] Autocompletion for all attributes
Doesn't Java already do that for you? When I am looking at a new
instance of a class in the debugger it shows uninitialized elements as
'null'. I was assuming a newly allocated class had elements set to a
value of 0, which would give you numeric values of 0, a boolean of
false, and objects which a set to null.
For any non-zero values you would need to handle that in either a static
initializer method (for static values) or in your constructor method.
Or am I under a mis-conception as to how Java creates a new class instance? |
|
|
| Back to top |
|
 |
Snirf
Joined: 03 Jul 2009 Posts: 3
|
Posted: Wed Aug 19, 2009 9:05 am Post subject: Re: Autocompletion for all attributes |
|
|
Hi,
i'm sorry, the example wasn't precise enough. After the 'auto completion' i wanna set the attributes to other values but i want to avoid typing
for all attributes. And because Netbeans has already the information about the attributes (as you can see in the auto-completion after typing "myClass.") i thought about generating theses lines of code.
| Mike Riley wrote: | I agree. I was just asking if he really needed it, since his example was
simply wanting to set the various elements of the class to 0 or null. If
that is all he needed it seems his need for code completion does not really
exist.
Mike
Melongo Annabel wrote:
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|