create 1 static object or a class with static methods

i have the gui class and the logic class,
which is the better choice:

  1. make the logic class methods static and access them LogicClass.method() from the gui class.

  2. make the logic class regular and make 1 static object from this logic class

    private static LogicClass logic;

  3. make it non-static which is a little of a problem because i want to access some methods from the Main function in the guiClass so it has to be static(i can access them through the constructor but i dont know if that’s ok, something like connecting the server)

thanks

Projects that worked

I dropped the projects on the USB flash drive, reinstalled the window and then I threw the projects and they stopped working and started to give some errors, but before that they worked 100%, now started a new project, made it and launched it, it worked, run again and there was an error that occurred in those projects that were on the flash drive, but they worked.

Image showing the problem

Adding dependency using Maven to eclipse-pdt in pom.xml

I am trying to import the parser from Eclipse PDT in a project using Maven, however, I cannot find how to do it.

I added the following in pom.xml:

<dependency>
    <groupId>org.eclipse.php</groupId>
    <artifactId>org.eclipse.php.core</artifactId>
    <version>5.0.0-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>org.eclipse.php</groupId>
    <artifactId>org.eclipse.php.core.parser</artifactId>
    <version>5.0.0-SNAPSHOT</version>
</dependency>

However, these packages are not located on https://repo.maven.apache.org/maven2, like for example Eclipse JDT (org.eclipse.jdt)

Is there a maven repository from where these packages (org.eclipse.php.core, org.eclipse.php.core.parser) can be downloaded using Maven, together with all their dependencies?

Getting arduino door lock to work

i’d like to have a pre-defined rgb colour to display on my rgb strips and a predefined if statement which will make the leds blink and then fade, i’ve got the code but it’s not responding, also I can’t seem to get the wav files to play during my switch case and elsif statements, i’ve added everything ,all the libraries, setup,etc but the files won’t play(please note in the code show this is not the real names of the wav files).

Also how do I add a override password for the door lock and also after three tries of entering the password a warning message will be played.

Code_lover92
`#include <Adafruit_fingerprint.h>
#include <Keypad.h>
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

//ADD computer WHEN YOU HAVE SPEAKER SHIELD
//********************************
//computer pins use, 1,5, PCI Pins shared  11,12 and 13
//********************************
//adding computer
//#include "SD.h"
//#define SD_ChipSelectPin 5
//#include "TMRpcm.h"
//#include "SPI.h"

//TMRpcm tmrpcm;
//*********************************

//all used pins on arduino ,2,3,9 - LEDS, 8, 11, 7, 6, 5, 4-LCD, 1,5,11,12,13
//Defining the LED Pins
//#define greenPin 2 //unlocked
//#define redPin 3   //locked

//DEFINE LED STRIP FOR LOCKED/UNLOCKED FUNCTION
#define LED_RED 2//pin for red led
#define LED_GREEN 3//pin for green led
#define LED_BLUE 9//pin for blue led
#define FADESPEED 10//make this higher to slow down led fading time
#define delayTime 20// Delays led

//Defining the LED Pins Connected to the IRL Shields


SoftwareSerial mySerial(10,9);      // pin #10 is IN from sensor (GREEN wire) and pin #9 is OUT from arduino (WHITE wire)
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);


LiquidCrystal lcd(8, 11, 7, 6, 5, 4); // initialize the LCD library with the numbers of the interface pins

                            //initialize variables
int getFingerprintIDez();
int cursorColumn = 0;       //this controls the cursor postition
int menu = 0;               //this controls the menu settings 
int n=0;                    // variable used to point to the bits in the keypad input array
int addr=0;
char pswrdElement=0;
char a='0';                 //variables a,b,c,d are all zero by default and store each digit of the 4 digit passcode
char b='0';
char c='0';
char d='0';

char password[]={a,b,c,d}; //initializing an array called password with variables a,b,c,d that hold the password digits
char input[4];             // an array that will contain the digits that are input
const byte ROWS = 4;       // Four rows
const byte COLS = 4;       // Four columns

// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 15, 14, 13, 12 };

// Connect keypad COL0, COL1,COL2 and COL3 to these Arduino pins.
byte colPins[COLS] = { 19, 18, 17, 16 }; 


// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {

  // ADD CADBRUY HERE
  //********************************************8
  //tmrpcm.speakerPin = 1
  //Serial.begin(9600); //adds startup for program to begin
  //if (!SD.begin(SD.ChipSelectPin)) {
  //Serial.lcd.print("SD Fail"); //prints it on sketch
  //lcd.print("SD Failed";// prints error on lcd screen
  //return;
  //}

  //tmrpcm.setVolume(6); //sets volume
  //tmrpcm.play("computer.wav"); //this will play the file,
  //instead add this on loop, if this then play this file using
  //tmrpcm.play("file.wav");
  //}

  //LED STRIP SETUP HERE
  pinMode(LED_RED, OUTPUT);
  pinMode(LED_BLUE, OUTPUT);
  pinMode(LED_GREEN, OUTPUT);


  //FINGERPRINT SENSOR CODE HERE  
  //Set the time it takes for the fingerprint sensor to read the input
  finger.begin(57600);

  lcd.begin(16, 2); //Sets up the LCD Columns and rows on the keypad
  lcd.print("Welcome,I'm computer how may I be of assistance?"); //prints a message to the lcd screen on startup

  pinMode(greenPin, OUTPUT);
  pinMode(redPin, OUTPUT); //sets the pin used for the red and green leds as outputs

  analogWrite(LED_GREEN, HIGH); //activates the green led to show on startup the door is locked

  int redVal;
  int blueVal;
  int greenVal;
}

void loop() {
  // put your main code here, to run repeatedly:
  int r, g, b; //start rgb
  //violet rgb code 167, 66, 244
  //teal rgb colour 0, 255, 255
  //setup door lock first

 //keypad setup with keys
 // set the data rate for the sensor serial port
  finger.begin(57600);

  lcd.begin(16, 2);    // set up the LCD's number of columns and rows:
  printIN("DOOR LOCK")         // Prints a message to the LCD.

  pinMode(greenPin,OUTPUT);    
  pinMode(redPin,OUTPUT);      //set the pin used for the red and green LED's as outputs
  digitalWrite(redPin,HIGH);   // intially activate the Red LED to indicate that the door is locked  
}

void loop()
{
  readKeypad();                 // Handles the Keypad object and switch case to read the inputs and decides the output state and leds based on the input    
} 


void askForCode(){
  lcd.print("Please enter the door password, thank you kindly");  //prints when the user wants to enter the code
  tmrpcm.play(enter door password.wav); //**NEEDS TO BE UPDATED
}

void readKeypad(){
  char key = kpd.getKey();
  lcd.setCursor(cursorColumn,1);          // set the cursor to column "cursorColumn", line 1
  if(key)                      // Check for a valid key.
  {
    switch (key)
    {
      case '0':                                 // Each case is a button that is pressed
        if(menu == 1){                          // the value of "menu" determines the setting parameter and what each button does in that setting  
          lcd.print('0');
          cursorColumn=cursorColumn+1;
          input[n]='0';
          n=n+1;
        }
        else if(menu == 3){
          lcd.print('0');
          cursorColumn=cursorColumn+1;
          input[n]='0';
          n=n+1;
        }
        else if(menu == 4){
          lcd.print('0');
          cursorColumn=cursorColumn+1;
          input[n]='0';
          n=n+1;
        }
        break;
      case '1':
        if(menu == 1){
        lcd.print('1');
          cursorColumn=cursorColumn+1;
          input[n]='1';
          n=n+1;
        }
        else if(menu == 3){
          lcd.print('1');
          cursorColumn=cursorColumn+1;
          input[n]='1';
          n=n+1;
        }
        else if(menu == 4){
          lcd.print('1');
          cursorColumn=cursorColumn+1;
          input[n]='1';
          n=n+1;
        }
        break;
      case '2':
        if(menu == 1){
          lcd.print('2');
          cursorColumn=cursorColumn+1;
          input[n]='2';
          n=n+1;
        }
        else if(menu == 3){
          lcd.print('2');
          cursorColumn=cursorColumn+1;
          input[n]='2';
          n=n+1;
        }
        else if(menu == 4){
          lcd.print('2');
          cursorColumn=cursorColumn+1;
          input[n]='2';
          n=n+1;
        }
        break;
      case '3':
        if(menu == 1){
          lcd.print('3');
          cursorColumn=cursorColumn+1;
          input[n]='3';
          n=n+1;
        }
        else if(menu == 3){
          lcd.print('3');
          cursorColumn=cursorColumn+1;
          input[n]='3';
          n=n+1;
        } 
        else if(menu == 4){
          lcd.print('3');
          cursorColumn=cursorColumn+1;
          input[n]='3';
          n=n+1;
        }
        break;
      case '4':
        if(menu == 1){
          lcd.print('4');
          cursorColumn=cursorColumn+1;
          input[n]='4';
          n=n+1;
        }
        else if(menu == 3){
          lcd.print('4');
          cursorColumn=cursorColumn+1;
          input[n]='4';
          n=n+1;
        }
        else if(menu == 4){
          lcd.print('4');
          cursorColumn=cursorColumn+1;
          input[n]='4';
          n=n+1;
        }
        break;
      case '5':
        if(menu == 1){
          lcd.print('5');
          cursorColumn=cursorColumn+1;
          input[n]='5';
          n=n+1;
        }
        else if(menu == 3){
          lcd.print('5');
          cursorColumn=cursorColumn+1;
          input[n]='5';
          n=n+1;
        }
        else if(menu == 4){
          lcd.print('5');
          cursorColumn=cursorColumn+1;
          input[n]='5';
          n=n+1;
        }
        break;
      case '6':
        if(menu == 1){
          lcd.print('6');
          cursorColumn=cursorColumn+1;
          input[n]='6';
          n=n+1;
        }
        else if(menu == 3){
          lcd.print('6');
          cursorColumn=cursorColumn+1;
          input[n]='6';
          n=n+1;
        }
        else if(menu == 4){
          lcd.print('6');
          cursorColumn=cursorColumn+1;
          input[n]='6';
          n=n+1;
        }
        break;
      case '8':
        if(menu == 1){
          lcd.print('8');
          cursorColumn=cursorColumn+1;
          input[n]='8';
          n=n+1;
        }
        else if(menu == 3){
          lcd.print('8');
          cursorColumn=cursorColumn+1;
          input[n]='8';
          n=n+1;
        }
        else if(menu == 4){
          lcd.print('8');
          cursorColumn=cursorColumn+1;
          input[n]='8';
          n=n+1;
        }
        break;
      case '9':
        if(menu == 1){
          lcd.print('9');
          cursorColumn=cursorColumn+1;
          input[n]='9';
          n=n+1;
        }
        else if(menu == 3){
          lcd.print('9');
          cursorColumn=cursorColumn+1;
          input[n]='9';
          n=n+1;
        }
        else if(menu == 4){
          lcd.print('9');
          cursorColumn=cursorColumn+1;
          input[n]='9';
          n=n+1;
        }
        break;   
      case '7':
        if(menu == 1){
          lcd.print('7');
          cursorColumn=cursorColumn+1;
          input[n]='7';
          n=n+1;
        break;
        }
        else if(menu == 3){
          lcd.print('7');
          cursorColumn=cursorColumn+1;
          input[n]='7';
          n=n+1;
        }
        else if(menu == 4){
          lcd.print('7');
          cursorColumn=cursorColumn+1;
          input[n]='7';
          n=n+1;
        }   
      case 'A':
        if(menu == 0){
          lcd.setCursor(0,0);
          askForCode();
          lcd.setCursor(0,1);
          menu=menu+1;
        }
        break;
      case 'B':
        if(menu == 0){
          lcd.setCursor(0,0);
          lcd.print("would you like to change the password?");
          tmrpcm.play(wouldyouliketochangepassword.wav); //**NEEDS TO BE UPDATED
          lcd.setCursor(0,1);
          menu=menu+2;
        }
      case 'C':

        break;   
      case 'D':
        reset();
        break;
      case '*':
        if(menu == 2){
          lcd.setCursor(0,0);
          lcd.print("Please enter the old password, thank you");
          tmrpcm.play(enteroldpassword.wav); //**NEEDS TO BE UPDATED
          lcd.setCursor(0,1);
          menu=menu+1;
        }  
      default:
       return; 
    }
  } 
  if(menu==1 && n > 3){                             //If the menu is in setting 1 and the input array has been filled with 4 digits then...
    doorlockCheck();    //calls the function to check whether the code that was input matches the code that is stored
  }
  else if(menu==3 && n > 3){
    oldCodeCheck();  
  }
  //overridepassword add later
  //else if(menu==5 && 1234 > n){ //**NEEDS TO BE UPDATED add real overide code
  //    overideCheck();
  //}
  else if(menu==4 && n > 3){
  changeToNewCode(password,input);
  delay(250); 
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("The password has been updated master, please memorize the new password, thank you Madam");
  tmrpcm.play(passwordchangetrue.wav); //**NEEDS TO BE UPDATED
  delay(1000);
  reset();
  }
  if(checkCode(password,input) == true){
    getFingerprintIDez();
    delay(50);
  }

//controls lcd screen turn off if no key is pressed or stays on
    if (key != key)
    {
     lcd.print("Keypad Timed out, press any button to restart");
     tmrpcm.play(keypadtimeout.wav); //**NEEDS TO BE UPDATED
     lcd.noDisplay(true);
    }
    else (key = key)
      {
      lcd.print("Hello this is computer Please place your fingerprint on the sensor or enter the password please, Thank you");
      tmrpcm.play("computer key pressed startup.wav"); //plays cadburies phrase as written above
      lcd.noDisplay(false);
  }
//begining of keypad lock
boolean checkCode(char *a,char *b){                   //The function to check whether the contents of the first parameter,an array, match the 
  int p;                                              //match the contents of the second parameter, also an array.
  for(p=0; p<4; p++) 
    if(a[p]!=b[p]) return false;
    return true;
}

int changeToNewCode(char *a, char *b){
  int p = 0;
  for(p=0; p<4; p++){
    a[p]=b[p];
  } 
  n=0;
}

int doorlockCheck(){
  if(n > 3){
   if(checkCode(password,input) == true){
     delay(250);
     lcd.clear();
     lcd.setCursor(0,0);
     lcd.print("Password Accepted"); 
     tmrpcm.play(passwordaccepted.wav); //**NEEDS TO BE UPDATED
     //found a match! Teal = Access Granted
     //displays colour when fingerprint matched **CHECK IF IT WORKS**
     int teal = 0,255,255;
     int redVal = 0;
     int blueVal = 255;
     int greenVal = 255;
     digitalWrite(teal,HIGH);
     delay(1000);
     digitalWrite(teal, LOW);
     delay(1000);
     digitalWrite(teal, HIGH);
     digitalWrite(teal, FADESPEED); //makes leds fade
     fingerCheck(); 
   }
  else{
   delay(250);
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Code invalid, you have three more tries before an image will be take of you and sent to my master");
   tmrpcm.play(photowarningforinvalidpassword.wav); //**NEEDS TO BE UPDATED
   delay(2000);
   int violet = 167, 66, 244;
   digitalWrite(violet, HIGH);
   delay(1000);
   digitalWrite(violet, LOW);
   delay(1000);
   digitalWrite(violet, HIGH);    
   digitalWrite(violet, FADESPEED); //MAKES LEDS FADE AFTER BLINKING


   reset();

   cursorColumn=0;
   n=0;
  }
}

int oldCodeCheck(){
  if(n > 3){
   if(checkCode(password,input) == true){
     delay(250);  
     lcd.clear();
     lcd.setCursor(0,0);
     lcd.print("Password Accepted"); 
     tmrpcm.play(passwordaccepted.wav); //*NEEDS TO BE UPDATED

     delay(1000);
     int teal = 0,255,255;
     int redVal = 0;
     int blueVal = 255;
     int greenVal = 255;
     digitalWrite(teal,HIGH);
     delay(1000);
     digitalWrite(teal, LOW);
     delay(1000);
     digitalWrite(teal, HIGH);
     digitalWrite(teal, FADESPEED); //makes leds fade
     lcd.clear();
     lcd.setCursor(0,0);
     lcd.print("Enter new Code");
     menu=4;
   }
  else{
   delay(250);
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Invalid Code you have three more tries, until an image of you will be sent to my master thank you for your time");
   tmrpcm.play("invalid code pic sent.wav") //**NEEDS TO BE UPDATED 
   delay(2000);
   int violet = 167, 66, 244;
   digitalWrite(violet, HIGH);
   delay(1000);
   digitalWrite(violet, LOW);
   delay(1000);
   digitalWrite(violet, HIGH);
   digitalWrite(violet, FADESPEED); //MAKES LEDS FADE AFTER BLINKING
   reset();
    } 
   n=0; 
   cursorColumn=0;
  }
}

void reset(){
  int i;
  cursorColumn=0;
  lcd.clear();
  lcd.setCursor(0,0);

  printIN("DOOR LOCK");
  menu=0;
  n=0;
  for(i=0;i<4;i++){
    input[i]='r';
  }
  digitalWrite(LED_BLUE,HIGH);
  digitalWrite(LED,LOW);
}

void fingerCheck(){
  if (finger.verifyPassword()) {
    lcd.clear();
    lcd.setCursor(0,0);
    printIN("Senor Found!");
  }
  else {
    lcd.clear();
    lcd.setCursor(0,0);
    printIN("Did not find fingerprint sensor :(");
    while (1);
  }
  lcd.setCursor(0,1);
  printIN("Waiting..."); 
  return ;
}

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Your Fingerprint is being assessed, Just a moment please");
      tmrpcm.play(readingfingerprint.wav) //**NEEDS TO BE UPDATED
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("Fingerprint not detected, Please place your finger firmly but gently in the centre of the sensor please");
      tmrpcm.play(fingerpirtnotedetected.wav); //**NEEDS TO BE UPDATED
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("My sincerest apologies my circuits are not being friendly and therefore they are not communicating together, please try again");
      tmrpcm.play("circuits not working.wav") //NEEDS TO BE UPDATED
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("There was an imaging error, please place your finger on the sensor again, thank you");
      tmrpcm.play(imagingerror.wav) //**NEEDS TO BE UPDATED
      return p;
    default:
      Serial.println("Unknown error please try again");
      tmrpcm.play(unkownerror.wav); //**NEEDS TO BE UPDATED
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.lcd.print("Access Granted Welcome Back");
    tmrpcm.play("computer welcome back.wav"); //**Must be updated
    int teal = 0,255,255;
    digitalWrite(teal, HIGH); //Glows teal **MUST BE CHECKED
    delay(1000);
    digitalWrite(teal, LOW);
    delay(1000);
    digitalWrite(teal, HIGH); //makes leds blink
    digitalWrite(teal, FADESPEED); //Makes LEDS Fade after blinking
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error between my circuits, Please try again");
    tmrpcm.play("play communicationerror.wav")  //**NEEDS TO BE UPDATED
    digitalWrite(LED_RED, HIGH); //led red light
    delay(1000);
    digitalWrite(LED_RED, LOW);
    delay(1000);
    digitalWrite(LED_RED,HIGH) 
    digitalWrite(LED_RED, FADESPEED);

    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("My Apologies But Access is Denied, Your Fingerprint and PHOTO ID Has been SENT to my Master Thank you for your time have a nice day :)");
    tmrpcm.play("accessdenied.wav") //**must be updated with access denied wav file    
    int violet = 167, 66, 244;
    digitalWrite(violet, HIGH);
    delay(1000);
    digitalWrite(violet, LOW);
    delay(1000);
    digitalWrite(violet, HIGH);
    digitalWrite(violet, FADESPEED); //MAKES LEDS FADE AFTER BLINKING
    return p;
  } else {
    Serial.println("Unknown error please try again");
    return p;
  }   

  // found a match!
  Serial.print("Congratulations it's a match!"); Serial.print(finger.fingerID); 
  Serial.print("Welcome back ADD NAME HERE"); Serial.println(finger.confidence); //**NEEDS TO BE UPDATED
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;

  // found a match! Teal = Access Granted
  //displays colour when fingerprint matched **CHECK IF IT WORKS**
  int teal = 0,255,255;
  int redVal = 0;
  int blueVal = 255;
  int greenVal = 255;
  digitalWrite(teal,HIGH);
  delay(1000);
  digitalWrite(teal, LOW);
  delay(1000);
  digitalWrite(teal, HIGH);
  digitalWrite(teal, FADESPEED); //makes leds fade



  lcd.clear();
  lcd.print("Fingerprint Accepted"); lcd.print(finger.fingerID); 
  lcd.setCursor(0,1);
  lcd.print("Welcome Back"); lcd.print("add name here"); //**UPDATE THIS PART
  delay(5000);
  reset();
  return finger.fingerID; 
}




  }
 `

Apache Jena automatically merge object properties together

I am very new in using Apache Jena. I am facing a problem here.

I designed an RDF file using Protege. Basically, I have three object properties which are ASSOCIATION, AGGREGATION, & COMPOSITION.
Both AGGREGATION & COMPOSITION are sub property of ASSOCIATION. As you can here from Protege these three objects are generated nicely together.

However when I use Jena with Java (below is my code), the output generated is different from the expected outcome.

Model m = ModelFactory.createDefaultModel();
String NS = “http://example.com/test/“;

  OntModel ontoModel = >ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);     

  ObjectProperty ASSOCIATION = ontoModel.createObjectProperty(NS + >"ASSOCIATION");
  ObjectProperty AGGREGATION = ontoModel.createObjectProperty(NS + >"AGGREGATION");
  AGGREGATION.addProperty(RDFS.subPropertyOf, ASSOCIATION);
  ObjectProperty COMPOSITION = ontoModel.createObjectProperty(NS + >"COMPOSITION");
  COMPOSITION.addProperty(RDFS.subPropertyOf, ASSOCIATION);

As you can see in the output generated:

1) The ASSOCIATION object property is nested below the AGGREGATION & COMPOSITION.

2) The way sub property of AGGREGATION & COMPOSITION is generated is different.

Any help here is very much appreciated.

Expected output generated from Protege & output generated with Jena

Thank you.

Merging two Map with Java 8 Stream API

I have two (or more) Map<String, Integer> objects. I’d like to merge them with Java 8 Stream API in a way that values for common keys should be the maximum of the values.

@Test
public void test14() throws Exception {
    Map<String, Integer> m1 = ImmutableMap.of("a", 2, "b", 3);
    Map<String, Integer> m2 = ImmutableMap.of("a", 3, "c", 4);
    List<Map<String, Integer>> list = newArrayList(m1, m2);

    Map<String, Integer> mx = list.stream()... // TODO

    Map<String, Integer> expected = ImmutableMap.of("a", 3, "b", 3, "c", 4);
    assertEquals(expected, mx);
}

How can I make this test method green?

I’ve played with collect and Collectors for a while without any success.

(ImmutableMap and newArrayList are from Google Guava.)

actionlistener not working primefaces

Estimated Greetings:

I have a problem with hibernate and primefaces, my code is as follows:

empleadoDao:

public void nuevoEmpleado (Tbempleado tbempleado);

empleadoDaoImp:

@Override
public void nuevoEmpleado(Tbempleado tbempleado){
    Session session = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();
        session.save(tbempleado);
        session.getTransaction().commit();
    }catch(Exception ex){
        System.out.println("error"+ex.getMessage());
        session.getTransaction().rollback();
    }finally{
        if(session!=null){
            session.close();
        }
    }
}

empleadoBean:

public void nuevoEmpleado() {
    empleadoDao eDao = new empleadoDaoImp();
    eDao.nuevoEmpleado(empleado);
    empleado = new Tbempleado();
}

My form index.xhtml of button:

<p:commandButton value="Guardar" actionListener="#{empleadoBean.nuevoEmpleado()}" />

Thank you in advance.

Android Google Vision API TextRecognizer isOperational always returns false

I want to try one of google vision api on android. I added this line in gradle file

compile 'com.google.android.gms:play-services-vision:10.0.0'

also in manifest file I added this

 <meta-data
            android:name="com.google.android.gms.vision.DEPENDENCIES"
            android:value="ocr" />

And here’s the code snippet

TextRecognizer textRecognizer = new TextRecognizer.Builder(this).build();
        try {
            if (!textRecognizer.isOperational()) {
                new AlertDialog.
                        Builder(this).
                        setMessage("Text recognizer could not be set up on your device").show();
                return;
            }
}

So here textRecognizer.isOperational() always returns false. I looked to other questions and found nothing that helped me. (Device storage left 4 gb, so it’s not storage issue). What I’m missing?

Alphabet palindrome

Program which will take input as an alphabet (case sensitive). Find the ascii value of the letter and and display the next number which is a palindrome, if any double alphabets, Alphanumeric or numbers are given as input we will display a message ‘invalid input’.

Sample:i/p a B Z
O/p 99 66 131

Where to put a flag for extended debugging info?

I’m currently in trouble with serialization, but I found this nice flag which will help me debugging:

-Dsun.io.serialization.extendedDebugInfo=true

My problem is, that after hours of research I still don’t know how to use it. I tried to simply write it down in my main method, but that doesn’t work.

Where do I have to put this flag?

I use eclipse, so I wonder if I have to edit the settings as well?