use of org.jetbrains.annotations.NotNull in project qi4j-sdk by Qi4j.
the class AbstractCreateElementActionBase method invokeDialog.
@NotNull
protected final PsiElement[] invokeDialog(Project project, PsiDirectory directory) {
Module module = ModuleUtil.findModuleForFile(directory.getVirtualFile(), project);
if (module == null) {
return PsiElement.EMPTY_ARRAY;
}
MyInputValidator validator = doInvokeDialog(project, directory);
return validator.getCreatedElements();
}
use of org.jetbrains.annotations.NotNull in project qi4j-sdk by Qi4j.
the class Qi4jConcernUtil method addOrReplaceConcernAnnotation.
@NotNull
public static PsiAnnotation addOrReplaceConcernAnnotation(@NotNull PsiModifierListOwner modifierListOwner, @NotNull PsiClass concernClassToAdd) {
Project project = modifierListOwner.getProject();
JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
PsiElementFactory factory = psiFacade.getElementFactory();
PsiAnnotation existingConcernsAnnotation = findAnnotation(modifierListOwner, QUALIFIED_NAME_CONCERNS);
boolean isReplace = false;
PsiAnnotation newConcernsAnnotation;
if (existingConcernsAnnotation != null) {
// Check duplicate
List<PsiAnnotationMemberValue> concernsValues = getConcernsAnnotationValue(existingConcernsAnnotation);
for (PsiAnnotationMemberValue concernValue : concernsValues) {
PsiJavaCodeReferenceElement concernClassReference = getConcernClassReference(concernValue);
if (concernClassReference == null) {
continue;
}
PsiElement concernClass = concernClassReference.resolve();
if (concernClassToAdd.equals(concernClass)) {
return existingConcernsAnnotation;
}
}
isReplace = true;
}
String concernAnnotationText = createConcernAnnotationText(existingConcernsAnnotation, concernClassToAdd);
newConcernsAnnotation = factory.createAnnotationFromText(concernAnnotationText, modifierListOwner);
if (isReplace) {
// Replace @Concerns instead
existingConcernsAnnotation.replace(newConcernsAnnotation);
} else {
// @Concerns doesn't exists, add it as first child
PsiModifierList modifierList = modifierListOwner.getModifierList();
modifierList.addBefore(newConcernsAnnotation, modifierList.getFirstChild());
}
// Shorten all class references if possible
JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project);
codeStyleManager.shortenClassReferences(newConcernsAnnotation);
return newConcernsAnnotation;
}
use of org.jetbrains.annotations.NotNull in project qi4j-sdk by Qi4j.
the class Qi4jServiceAnnotationUtil method isValidServiceAnnotationDeclaration.
/**
* Validates whether the variable has {@code @Service} annotation declared correctly.
*
* @param variable variable to check.
* @return Look at {@link ServiceAnnotationDeclarationValidationResult}.
* @since 0.1
*/
@NotNull
public static ServiceAnnotationDeclarationValidationResult isValidServiceAnnotationDeclaration(@NotNull PsiVariable variable) {
PsiAnnotation serviceAnnotation = getServiceAnnotation(variable);
if (serviceAnnotation == null) {
return invalidServiceAnnotationNotDeclared;
}
PsiModifierList modifierList = variable.getModifierList();
if (modifierList != null) {
if (modifierList.hasModifierProperty(STATIC)) {
return invalidDeclaredOnStaticVariable;
}
}
// Can't be type that is injected by @Structure
if (isInjecteableByStructureAnnotation(variable)) {
return invalidTypeIsInjectedViaStructureAnnotation;
}
return valid;
}
use of org.jetbrains.annotations.NotNull in project actor-platform by actorapp.
the class PeerConnectionActor method onOffer.
public void onOffer(final long sessionId, @NotNull String sdp) {
// Ignore if we are not waiting for handshake
if (state != PeerConnectionState.WAITING_HANDSHAKE) {
return;
}
// Ignore if we already have session id
if (this.sessionId != -1) {
return;
}
//
// Stages
// 1. Set Remote Description
// 2. Create Answer
// 3. Set Local Description
// 4. Send Answer
// 5. Enter READY mode
//
isReady = false;
peerConnection.setRemoteDescription(new WebRTCSessionDescription("offer", sdp)).flatMap(description -> {
return peerConnection.createAnswer();
}).flatMap(webRTCSessionDescription -> {
return peerConnection.setLocalDescription(SDPOptimizer.optimize(webRTCSessionDescription));
}).then(webRTCSessionDescription -> {
callback.onAnswer(sessionId, webRTCSessionDescription.getSdp());
PeerConnectionActor.this.sessionId = sessionId;
onHandShakeCompleted(sessionId);
onReady();
}).failure(e -> {
e.printStackTrace();
onHandshakeFailure();
});
}
use of org.jetbrains.annotations.NotNull in project actor-platform by actorapp.
the class ContactContent method create.
@NotNull
public static ContactContent create(@NotNull String name, @NotNull ArrayList<String> phones, @NotNull ArrayList<String> emails, @Nullable String base64photo) {
try {
JSONObject obj = new JSONObject();
obj.put("dataType", "contact");
JSONObject contact = new JSONObject();
contact.put("name", name);
if (base64photo != null) {
contact.put("photo", base64photo);
}
JSONArray phoneArray = new JSONArray();
for (String phone : phones) {
phoneArray.put(phone);
}
JSONArray emailArray = new JSONArray();
for (String phone : emails) {
emailArray.put(phone);
}
contact.put("emails", emailArray);
contact.put("phones", phoneArray);
JSONObject data = new JSONObject();
data.put("contact", contact);
obj.put("data", data);
return new ContactContent(new ContentRemoteContainer(new ApiJsonMessage(obj.toString())));
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
Aggregations