Intellij Extract Inner Class - android-studio

How does one who is using IntelliJ or Android Studio extract a public static inner class to create a new top level class?
Thank you.

Select the class name.
Refactor > Move or press F6
Select "Move inner class Foo to upper level"

Related

A white symbol on a java class in Android Studio 3.5.3

There is a weird white symbol (Like hammer) in one of my FirestoreStaticHelper.java. Like this (top of C)
FirestoreStaticHelper class only have static methods and private constructor. I have other similar classes like this. but only this class is showing this symbol.
What is this symbol?
How to remove it?
Take a look at this answer
Your FirestoreStaticHelper class is a final class. That's why there is a pin in that icon. If you want to remove it you have to remove final keyword from the class

IntelliJ : Add a class method to one of the interfaces it implements

I have a "C" class that implements two interfaces (lets call them "IAlpha" and "IBeta").
I created a new method a method on my C class that I want to push up to the IAlpha interface.
Is there a way to do this ?
I tried to use Right click on method->Extract->Interface, but it seems to work only to create the whole Interface from a class and not for appending.
As answered here by CrazyCoder (thanks), the solution is to :
Right click on the method -> Refactor -> Pull members Up...
Then you will be able to select the Interface on the dropdown menu.

How to automatically generate getters and setters in Android Studio

Is there a shortcut in Android Studio for automatically generating the getters and setters in a given class?
Using Alt+ Insert for Windows or Command+ N for Mac in the editor, you may easily generate getter and setter methods for any fields of your class. This has the same effect as using the Menu Bar -> Code -> Generate...
and then using shift or control button, select all the variables you need to add getters and setters
for macOS, ⌘+N by default.
Right-click and choose "Generate..." to see current mapping. You can select multiple fields for which to generate getters/setters with one step.
See http://www.jetbrains.com/idea/webhelp/generating-getters-and-setters.html
Android Studio & OSx :
Press cmd+n > Generate > Getter and Setter
Android Studio & Windows :
Press Alt + Insert > Generate > Getter and Setter
create the variable
right click
select "Generate" and then select "Getter and Setter" option
Android Studio & Windows :
fn + alt + insert
You can generate getter and setter by following steps:
Declare variables first.
click on ALT+Insert on keyboard placing cursor down to variable declaration part
now select constructor and press Ctrl+A on keyboard and click on Enter to create constructor.
Now again placing cursor at next line of constructor closing brace , click ALT+INSERT and select getter and setter and again press CTRL+A to select all variables and hit Enter.
That's it. Happy coding!!
Position the cursor under the variables -> right-click -> Generate -> Getter and Setter -> Choose the variables to make the get and set
or
Alt + Insert -> Getter and Setter -> Choose the variables
As noted here, you can also customise the getter/setter generation to take prefixes and suffixes (e.g. m for instance variables) into account. Go to File->Settings and expand Code Style, select Java, and add your prefixes/suffixes under the Code Generation tab.
Using Alt+ Insert or Right-click and choose "Generate..."
You may easily generate getter and setter or Override methods in Android Studio.
This has the same effect as using the Menu Bar Code -> Generate...
This answer deals with your question but is not exactly an answer to it. =) It's an interesting library I found out recently and I want to share with you.
Project Lombok can generate common methods, such as getters, setters, equals() and hashCode(), toString(), for your classes automatically. It replaces them with annotations reducing boilerplate code. To see a good example of code written using Lombok watch a video on the main page or read this article.
Android development with Lombok is easy and won't make your android application any 'heavier' because Lombok is a compile-time only library. It is important to configure your Android project properly.
Another example:
import lombok.Getter;
import lombok.Setter;
public class Profile {
#Getter #Setter
private String username;
#Getter #Setter
private String password;
}
Android development with Lombok is possible. Lombok should be a compile-time only dependency, as otherwise the entirety of Lombok will end up in your DEX files, wasting precious space. Gradle snippet:
dependencies {
compileOnly "org.projectlombok:lombok:1.16.18"
}
In addition you may want to add the Lombok IntelliJ plugin to support Lombok features in your IDE at development time. Also there is Hrisey library which is based on Lombok. Simply put, it's Lombok + Parcellable support.
You can use AndroidAccessors Plugin of Android Studio to generate getter and setter without m as prefix to methods
Ex: mId;
Will generate getId() and setId() instead of getmId() and setmId()
Use Ctrl+Enter on Mac to get list of options to generate setter, getter, constructor etc
use code=>generate=>getter() and setter() dialog ,select all the variables ,generate all the getter(),setter() methods at one time.
Another funny way
Type the parameter name anywhere in the object after definition, you will see setter and getter, Just select and click enter :)
I tried with Android Studio 2.3
Right click on Editor then Select Source -> Generate Getters and Setters or press Alt + Shift + S
Just in case someone is working with Eclipse
Windows 8.1 OS | Eclipse Idle Luna
Declare top level variable private String username Eclipse kindly generate a warning on the left of your screen click that warning and couple of suggestions show up, then select generate.

How do I add new class to my project in Visual C++ 6

I want to add a new class to my Visual C++ 6 project using Class Wizard. I don't want this class to inherit from anything. My class has a function to accept input as integer, and process it
The Class Wizard requires me to add a base class and a DialogID . Which one of the base classes and dialog ID shoud I select? I'm a C# developer and find it really annoying. Should I mannually add my class? How do i do it in Visual C++ 6
Don't use Class Wizard (which is for creating visual dialogs and is why it wants a dialog id).
Use Project->Add from the menu. There are several other types of things you can add to your project that don't involve visual dialogs, like header (.h) and source code (.cpp) files.

staruml abstract classes?

does anyone know how to create an abstract class using StarUML? I couldnt find any mention in the documentation.
Is there some sort of more general concept which mirrors an abstract class?
select class from toolBox and add it to canvas, then go to properties select isAbstract checkbox.
then class name appears italic.
Migrated from comment
This tutorial creates an abstract class.
http://cnx.org/content/m15092/latest
View menu > select Editors > select class name and/or method in class diagram > Poperty window > select isAbstract > you'll see your class name and/or method in italics

Resources