public Either<B, A> swap() { A vLeft = null; B vRight = null; if (left.isDefined()) { vLeft = left.get(); } if (right.isDefined()) { vRight = right.get(); } return new Either<B, A>(vRight, vLeft); }
public <X> Either<A, B> fold(Action<A> fa, Action<B> fb) { if (isLeft()) { fa.apply(left.get()); return new Either<A, B>(left.get(), null); } else if (isRight()) { fb.apply(right.get()); return new Either<A, B>(null, right.get()); } else { return new Either<A, B>(null, null); } }
public <X> Option<X> fold(Function<A, X> fa, Function<B, X> fb) { if (isLeft()) { return Option.maybe(fa.apply(left.get())); } else if (isRight()) { return Option.maybe(fb.apply(right.get())); } else { return (Option<X>) Option.none(); } }
static boolean validateCrossDomainAdminGrant(Right right, GranteeType granteeType) throws ServiceException { if (right == Admin.R_crossDomainAdmin && granteeType != GranteeType.GT_DOMAIN) { throw ServiceException.INVALID_REQUEST( "grantee for right " + Admin.R_crossDomainAdmin.getName() + " must be a domain.", null); } if (right != Admin.R_crossDomainAdmin && granteeType == GranteeType.GT_DOMAIN) { throw ServiceException.INVALID_REQUEST( "grantee for right " + right.getName() + " cannot be a domain.", null); } return right == Admin.R_crossDomainAdmin; }
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); picturePaint1 = new PicturePaint(); Advance = new javax.swing.JButton(); Right = new javax.swing.JButton(); Left = new javax.swing.JButton(); BackGround = new javax.swing.JPanel(); locationName = new javax.swing.JLabel(); Direction = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 462, Short.MAX_VALUE)); jPanel1Layout.setVerticalGroup( jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE)); Advance.setText("Forward"); Advance.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AdvanceActionPerformed(evt); } }); picturePaint1.add(Advance); Advance.setBounds(290, 500, 90, 50); Right.setText("Right"); Right.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RightActionPerformed(evt); } }); picturePaint1.add(Right); Right.setBounds(570, 500, 90, 50); Left.setText("Left"); Left.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LeftActionPerformed(evt); } }); picturePaint1.add(Left); Left.setBounds(0, 500, 80, 50); locationName.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N locationName.setForeground(new java.awt.Color(255, 255, 255)); locationName.setText("jLabel1"); Direction.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N Direction.setForeground(new java.awt.Color(255, 255, 255)); Direction.setText("jLabel1"); javax.swing.GroupLayout BackGroundLayout = new javax.swing.GroupLayout(BackGround); BackGround.setLayout(BackGroundLayout); BackGroundLayout.setHorizontalGroup( BackGroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( BackGroundLayout.createSequentialGroup() .addContainerGap(20, Short.MAX_VALUE) .addGroup( BackGroundLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, BackGroundLayout.createSequentialGroup() .addComponent( locationName, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, BackGroundLayout.createSequentialGroup() .addComponent(Direction) .addGap(28, 28, 28))))); BackGroundLayout.setVerticalGroup( BackGroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( BackGroundLayout.createSequentialGroup() .addComponent( locationName, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(Direction) .addGap(0, 19, Short.MAX_VALUE))); picturePaint1.add(BackGround); BackGround.setBounds(240, 10, 190, 80); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addComponent( jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(189, Short.MAX_VALUE)) .addComponent( picturePaint1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addComponent( picturePaint1, javax.swing.GroupLayout.PREFERRED_SIZE, 556, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); pack(); } // </editor-fold>//GEN-END:initComponents
public boolean isRight() { return right.isDefined(); }