@Override
    public ResponseEntity<AuditLogPagedResults> getLogEntries(
    		@ApiParam(value = "Environment ID", required = true) @PathVariable("environmentId") Long environmentId,
	   	  	@ApiParam(value = "ID of the queue manager to browse") @Valid @RequestParam(value = "queueManager", required = false) Long queueManager,
	   	  	@ApiParam(value = "ID of the queue to browse") @Valid @RequestParam(value = "queue", required = false) Long queue,
	   	  	@ApiParam(value = "Browse for messages newer than a date/time") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @RequestParam(value = "from", required = false) @Valid LocalDateTime from,
	   	  	@ApiParam(value = "Correlation ID to browse for") @Valid @RequestParam(value = "correlationId", required = false) String correlationId,
	   	  	@ApiParam(value = "Page of results to return") @Valid @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(value = "Number of results in a page") @Valid @RequestParam(value = "pagesize", required = false) Integer pagesize) {
        Pageable pageable = PageRequest.of(page != null ? page : 0, pagesize != null ? pagesize : defaultPageSize, new Sort(Sort.Direction.DESC, Audit.MSG_PUT_TIMESTAMP_FIELD));
        Page<Audit> auditEntries = null;
        Timestamp msgPut = (from != null ? Timestamp.valueOf(from) : null);

        /*
         * Environemnt is always supplied.  If we have queue or queue manager, assume that's what the caller wants.
         * We may also have some optional parameters - put timestamp, correlation ID
         */
        if (queue != null) {
        	//retrieve queue name
        	String queueName = null;
        	Optional<WMQQueue> queueEntity = wmqQueueRepository.findById(queue.intValue());
        	queueName = queueEntity.get().getQ_name();
        	
        	//see if we have timestamp or correlation ID
			if (msgPut != null) {
				if (correlationId != null) {
					auditEntries = auditRepository.findByQNameAndCorrelIdAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, correlationId, pageable);
				} else {
					auditEntries = auditRepository.findByQNameAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, pageable);
				}
			} else {
				if (correlationId != null) {
					auditEntries = auditRepository.findByQNameAndCorrelId(queueName, correlationId, pageable);
				} else {
					auditEntries = auditRepository.findByQName(queueName, pageable);
				}
			}
        } else if (queueManager != null) {
            List<Integer> managerIds = Arrays.asList(queueManager.intValue());
        	//see if we have timestamp or correlation ID
			if (msgPut != null) {
				if (correlationId != null) {
                    auditEntries = auditRepository.findByManagerIdsAndCorrelIdAndMsgPutTimestampGreaterThanEqual(managerIds, msgPut, correlationId, pageable);
				} else {
                    auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
				}
			} else {
				if (correlationId != null) {
                    auditEntries = auditRepository.findByManagerIdsAndCorrelId(managerIds, correlationId, pageable);
				} else {
                    auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
				}
			}
throw new java.lang.UnsupportedOperationException("Implementations does not exist");
        } else {
	        List<Integer> managerIds = findManagerIds(environmentId);
	
	        if(managerIds.isEmpty()) {
	            //No QueueManager so no possible log entries
	            return ResponseEntity.ok().body(null);
	        }
	
	        if (msgPut != null) {
	            auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
	        } else {
	            auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
	        }
        }
        
        
        /*
        if (correlationId != null && msgPut != null) {
            auditEntries = auditRepository.findByCorrelIdAndMsgPutTimestampGreaterThanEqual(correlationId, msgPut, pageable);
        } else if (queueName != null && msgPut != null) {
            auditEntries = auditRepository.findByQNameAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, pageable);
        } else if (queueName != null) {
            auditEntries = auditRepository.findByQName(queueName, pageable);
        } else if (correlationId != null) {
            auditEntries = auditRepository.findByCorrelId(correlationId, pageable);
        } else {
            List<Integer> managerIds = findManagerIds(environmentId);

            if(managerIds.isEmpty()) {
                //No QueueManager so no possible log entries
                return ResponseEntity.ok().body(null);
            }

            if (msgPut != null) {
                auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
            } else {
                auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
            }
        }
*/
        if (auditEntries != null) {
	        AuditLogPagedResults results = new AuditLogPagedResults();
	        results.setPageNumber(pageable.getPageNumber());
	        results.setPageSize(pageable.getPageSize());
	        results.setPages(auditEntries.getTotalPages());
	        results.setResults(mapperFacade.mapAsList(auditEntries.getContent(), AuditLogEntry.class));
	        return ResponseEntity.ok().body(results);
        } else {
        	throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Not found");
        }
    }

    
    /* (non-Javadoc)
	 * @see com.arcelormittal.springTemplate.web.MessagesApi#getLogEntry(java.lang.Long, java.lang.Long)
	 */
	@Override
	public ResponseEntity<AuditLogEntry> getLogEntry(Long environmentId, Long logId) {
		Optional<Audit> entry = auditRepository.findById(logId);
		if (entry.isPresent()) {
			return ResponseEntity.ok().body(mapperFacade.map(entry.get(), AuditLogEntry.class));
		} else {
			throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Not found");
		}
	}

End pint to do a dynamic query in JPA.

By Anonymous, 2019-10-02 23:31:22
boolean isUserAuthorized = user.isSuperAdmin();
if (!isUserAuthorized) {
    isUserAuthorized = isUserAdminOfEntity1();
}
if (!isUserAuthorized) {
    isUserAuthorized = isUserAdminOfEntity2();
}
if (!isUserAuthorized) {
    throw new AccessDeniedException("Authenticated user is not admin ");
}
By tralaladidou, 2019-05-07 16:37:32
public class Main {
    public static void main(String[] args) {
        try {
            //code goes here
        } catch (Exception e) {
            System.exit(0);
        }
    }
}
By s0m31, 2022-06-03 15:46:49
        if (CATEGORY_NORMAL.equalsIgnoreCase(categorie)) {
            return assignGroupStartWithPrefix(assignmentGroups);
        } else if (CATEGORY_EXTERNAL.equalsIgnoreCase(categorie)) {
            return assignGroupStartWithPrefix(assignmentGroups);
        } 
By Anon, 2019-05-14 13:58:23
import java.util.Scanner;

public class ConnectFour

{

    public static void main(String [] args) {

        Scanner scan;

        scan = new Scanner(System.in);

        boolean win = false;

        boolean oneone = false;

        boolean onetwo = false;

        boolean onethree = false;

        boolean onefour = false;

        boolean onefive = false;

        boolean onesix = false;

        boolean oneseven = false;

        boolean twoone = false;

        boolean twotwo = false;

        boolean twothree = false;

        boolean twofour = false;

        boolean twofive = false;

        boolean twosix = false;

        boolean twoseven = false;

        boolean threeone = false;

        boolean threetwo = false;

        boolean threethree = false;

        boolean threefour = false;

        boolean threefive = false;

        boolean threesix = false;

        boolean threeseven = false;

        boolean fourone = false;

        boolean fourtwo = false;

        boolean fourthree = false;

        boolean fourfour = false;

        boolean fourfive = false;

        boolean foursix = false;

        boolean fourseven = false;

        boolean fiveone = false;

        boolean fivetwo = false;

        boolean fivethree = false;

        boolean fivefour = false;

        boolean fivefive = false;

        boolean fivesix = false;

        boolean fiveseven = false;

        boolean sixone = false;

        boolean sixtwo = false;

        boolean sixthree = false;

        boolean sixfour = false;

        boolean sixfive = false;

        boolean sixsix = false;

        boolean sixseven = false;

        if(win = false) {

if(oneone = true) {

   if(onetwo = true) {

      if(onethree = true) {

          if(onefour = true) {

             winner = true;

          }

        }

     }

   else if(twotwo = true) {

       if(threethree = true) {

           if(fourfour = true) {

               winner = true;

            }

        }

    }

   else if(twoone = true) {

       if(threeone = true) {

           if(fourone = true) {

               winner = true;

            }

        }

    }

}

if(onetwo = true) {

    if(oneone = true) {

        if(onethree = true) {

            if(onefour = true) {

                winner = true;

            }

        }

    }

    if(onethree = true) {

        if(onefour = true) {

            if(onefive = true) {

                winner = true;

            }

        }

    }

    if(twothree = true) {

        if(threefour = true) {

            if(fourfive = true) {

                winner = true;

            }

        }

    }

    if(twotwo = true) {

        if(threetwo = true) {

            if(fourtwo = true) {

                winner = true;

            }

        }

    }

}

if(onethree = true) {

    if(oneone = true) {

        if(onetwo = true) {

            if(onefour = true) {

                winner = true;

            }

        }

    }

    if(onetwo = true) {

        if(onefour = true) {

            if(onefive = true) {

                winner = true;

            }

        }

    }

    if(onefour = true) {

        if(onefive = true) {

            if(onesix = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(threefive = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

    if(twothree = true) {

        if(threethree = true) {

            if(fourthree = true) {

                winner = true;

            }

        }

    }

}

if(onefour = true) {

    if(oneone = true) {

        if(onetwo = true) {

            if(onethree = true) {

                winner = true;

            }

        }

    }

    if(onetwo = true) {

        if(onethree = true) {

            if(onefive = true) {

                winner = true;

            }

        }

    }

    if(onethree = true) {

        if(onefive = true) {

            if(onesix = true) {

                winner = true;

            }

        }

    }

    if(onefive = true) {

        if(onesix = true) {

            if(oneseven = true) {

                winner = true;

            }

        }

    }

    if(twofive = true) {

        if(threesix = true) {

            if(fourseven = true) {

                winner = true;

            }

        }

    }

    if(twothree = true) {

        if(threetwo = true) {

            if(fourone = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(threefour = true) {

            if(fourfour = true) {

                winner = true;

            }

        }

    }

}

if(onefive = true) {

    if(onetwo = true) {

        if(onethree = true) {

            if(onefour = true) {

                winner = true;

            }

        }

    }

    if(onethree = true) {

        if(onefour = true) {

            if(onesix = true) {

                winner = true;

            }

        }

    }

    if(onefour = true) {

        if(onesix = true) {

            if(oneseven = true) {

                winner = true;

            }

        }

    }

    if(twofive = true) {

        if(threefive = true) {

            if(fourfive = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(threethree = true) {

            if(fourtwo = true) {

                winner = true;

            }

        }

    }

}

if(onesix = true) {

    if(onethree = true) {

        if(onefour = true) {

            if(onefive = true) {

                winner = true;

            }

        }

    }

    if(onefour = true) {

        if(onefive = true) {

            if(oneseven = true) {

                winner = true;

            }

        }

    }

    if(twosix = true) {

        if(threesix = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

    if(twofive = true) {

        if(threefour = true) {

            if(fourthree = true) {

                winner = true;

            }

        }

    }

}

if(oneseven = true) {

    if(onefour = true) {

        if(onefive = true) {

            if(onesix = true) {

                winner = true;

            }

        }

    }

    if(twoseven = true) {

        if(threeseven = true) {

            if(fourseven = true) {

                winner = true;

            }

        }

    }

    if(twosix = true) {

        if(threefive = true) {

            if(fourfour = true) {

                winner = true;

            }

        }

    }

}

if(twotwo = true) {

    if(twoone = true) {

        if(twothree = true) {

            if(twofour = true) {

                winner = true;

            }

        }

    }

    if(twothree = true) {

        if(twofour = true) {

            if(twofive = true) {

                winner = true;

            }

        }

    }

    if(threetwo = true) {

        if(fourtwo = true) {

            if(fivetwo = true) {

                winner = true;

            }

        }

    }

    if(onetwo = true) {

        if(threetwo = true) {

            if(fourtwo = true) {

                winner = true;

            }

        }

    }

    if(oneone = true) {

        if(threethree = true) {

            if(fourfour = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fourfour = true) {

            if(fivefive = true) {

                winner = true;

            }

        }

    }

}

if(twofour = true) {

    if(onethree = true) {

        if(threefive = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fourtwo = true) {

            if(fiveone = true) {

                winner = true;

            }

        }

    }

    if(onefive = true) {

        if(threethree = true) {

            if(fourtwo = true) {

                winner = true;

            }

        }

    }

    if(onethree = true) {

        if(threefive = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

    if(threefive = true) {

        if(foursix = true) {

            if(fiveseven = true) {

                winner = true;

            }

        }

    }

    if(onefour = true) {

        if(threefour = true) {

            if(fourfour = true) {

                winner = true;

            }

        }

    }

    if(threefour = true) {

        if(fourfour = true) {

            if(fivefour = true) {

                winner = true;

            }

        }

    }

    if(twoone = true) {

        if(twotwo = true) {

            if(twothree = true) {

                winner = true;

            }

        }

    }

    if(twotwo = true) {

        if(twothree = true) {

            if(twofive = true) {

                winner = true;

            }

        }

    }

    if(twothree = true) {

        if(twofive = true) {

            if(twosix = true) {

                winner = true;

            }

        }

    }

    if(twofive = true) {

        if(twosix = true) {

            if(twoseven = true) {

                winner = true;

            }

        }

    }

}

if(twosix = true) {

    if(twothree = true) {

        if(twofour = true) {

            if(twofive = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(twofive = true) {

            if(twoseven = true) {

                winner = true;

            }

        }

    }

    if(onesix = true) {

        if(threesix = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

    if(threesix = true) {

        if(foursix = true) {

            if(fivesix = true) {

                winner = true;

            }

        }

    }

    if(threefive = true) {

        if(fourfour = true) {

            if(fivethree = true) {

                winner = true;

            }

        }

    }

    if(fourfour = true) {

        if(fivethree = true) {

            if(oneseven = true) {

                winner = true;

            }

        }

    }

}

if(threeone = true) {

    if(fourone = true) {

        if(fiveone = true) {

            if(sixone = true) {

                winner = true;

            }

        }

    }

    if(oneone = true) {

        if(twoone = true) {

            if(fourone = true) {

                winner = true;

            }

        }

    }

    if(twoone = true) {

        if(fourone = true) {

            if(fiveone = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(threefive = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

    if(threetwo = true) {

        if(threethree = true) {

            if(threefour = true) {

                winner = true;

            }

        }

    }

}

if(threethree = true) {

    if(oneone = true) {

        if(twotwo = true) {

            if(fourfour = true) {

                winner = true;

            }

        }

    }

    if(twotwo = true) {

        if(fourfour = true) {

            if(fivefive = true) {

                winner = true;

            }

        }

    }

    if(fourfour = true) {

        if(fivefive = true) {

            if(sixsix = true) {

                winner = true;

            }

        }

    }

    if(onethree = true) {

        if(twothree = true) {

            if(fourthree = true) {

                winner = true;

            }

        }

    }

    if(twothree = true) {

        if(fourthree = true) {

            if(fivethree = true) {

                winner = true;

            }

        }

    }

    if(fourthree = true) {

        if(fivethree = true) {

            if(sixthree = true) {

                winner = true;

            }

        }

    }

    if(onefive = true) {

        if(twofour = true) {

            if(fourtwo = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(fourtwo = true) {

            if(fiveone = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fourtwo = true) {

            if(fiveone = true) {

                winner = true;

            }

        }

    }

    if(threeone = true) {

        if(threetwo = true) {

            if(threefour = true) {

                winner = true;

            }

        }

    }

    if(threetwo = true) {

        if(threefour = true) {

            if(threefive = true) {

                winner = true;

            }

        }

    }

    if(threefour = true) {

        if(threefive = true) {

            if(threesix = true) {

                winner = true;

            }

        }

    }

}

if(threefive = true) {

    if(onethree = true) {

        if(twofour = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(foursix = true) {

            if(fiveseven = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fourtwo = true) {

            if(fiveone = true) {

                winner = true;

            }

        }

    }

    if(oneseven = true) {

        if(twosix = true) {

            if(fourfour = true) {

                winner = true;

            }

        }

    }

    if(twosix = true) {

        if(fourfour = true) {

            if(fivethree = true) {

                winner = true;

            }

        }

    }

    if(fourfour = true) {

        if(fivethree = true) {

            if(sixtwo = true) {

                winner = true;

            }

        }

    }

    if(onefive = true) {

        if(twofive = true) {

            if(fourfive = true) {

                winner = true;

            }

        }

    }

    if(twofive = true) {

        if(fourfive = true) {

            if(fivefive = true) {

                winner = true;

            }

        }

    }

    if(fourfive = true) {

        if(fivefive = true) {

            if(sixfive = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fourtwo = true) {

            if(fiveone = true) {

                winner = true;

            }

        }

    }

    if(threetwo = true) {

        if(threethree = true) {

            if(threefour = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(threefour = true) {

            if(threesix = true) {

                winner = true;

            }

        }

    }

    if(threefour = true) {

        if(threesix = true) {

            if(threeseven = true) {

                winner = true;

            }

        }

    }

}

if(threeseven = true) {

    if(threefour = true) {

        if(threefive = true) {

            if(threesix = true) {

                winner = true;

            }

        }

    }

    if(sixfour = true) {

        if(fivefive = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

    if(oneseven = true) {

        if(twoseven = true) {

            if(fourseven = true) {

                winner = true;

            }

        }

    }

    if(twoseven = true) {

        if(fourseven = true) {

            if(fiveseven = true) {

                winner = true;

            }

        }

    }

    if(fourseven = true) {

        if(fiveseven = true) {

            if(sixseven = true) {

                winner = true;

            }

        }

    }

}

if(fourtwo = true) {

    if(fourone = true) {

        if(fourthree = true) {

            if(fourfour = true) {

                winner = true;

            }

        }

    }

    if(fourthree = true) {

        if(fourfour = true) {

            if(fourfive = true) {

                winner = true;

            }

        }

    }

    if(threeone = true) {

        if(fivethree = true) {

            if(sixfour = true) {

                winner = true;

            }

        }

    }

    if(onetwo = true) {

        if(twotwo = true) {

            if(threetwo = true) {

                winner = true;

            }

        }

    }

    if(twotwo = true) {

        if(threetwo = true) {

            if(fivetwo = true) {

                winner = true;

            }

        }

    }

    if(threetwo = true) {

        if(fivetwo = true) {

            if(sixtwo = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fourtwo = true) {

            if(fiveone = true) {

                winner = true;

            }

        }

    }

    if(fiveone = true) {

        if(threethree = true) {

            if(twofour = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fourtwo = true) {

            if(onefive = true) {

                winner = true;

            }

        }

    }

}

if(fourfour = true) {

    if(oneone = true) {

        if(twotwo = true) {

            if(threethree = true) {

                winner = true;

            }

        }

    }

    if(twotwo = true) {

        if(threethree = true) {

            if(fivefive = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fivefive = true) {

            if(sixsix = true) {

                winner = true;

            }

        }

    }

    if(oneseven = true) {

        if(twosix = true) {

            if(threefive = true) {

                winner = true;

            }

        }

    }

    if(twosix = true) {

        if(threefive = true) {

            if(fivethree = true) {

                winner = true;

            }

        }

    }

    if(threefive = true) {

        if(fivethree = true) {

            if(sixtwo = true) {

                winner = true;

            }

        }

    }

    if(fourone = true) {

        if(fourtwo = true) {

            if(fourthree = true) {

                winner = true;

            }

        }

    }

    if(fourtwo = true) {

        if(fourthree = true) {

            if(fourfive = true) {

                winner = true;

            }

        }

    }

    if(fourthree = true) {

        if(fourfive = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

    if(fourfive = true) {

        if(foursix = true) {

            if(fourseven = true) {

                winner = true;

            }

        }

    }

    if(onefour = true) {

        if(twofour = true) {

            if(threefour = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(threefour = true) {

            if(fivefour = true) {

                winner = true;

            }

        }

    }

    if(threefour = true) {

        if(fivefour = true) {

            if(sixfour = true) {

                winner = true;

            }

        }

    }

}

if(foursix = true) {

    if(fourthree = true) {

        if(fourfour = true) {

            if(fourfive = true) {

                winner = true;

            }

        }

    }

    if(fourfour = true) {

        if(fourfive = true) {

            if(fourseven = true) {

                winner = true;

            }

        }

    }

    if(onethree = true) {

        if(twofour = true) {

            if(threefive = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(threefive = true) {

            if(fiveseven = true) {

                winner = true;

            }

        }

    }

    if(sixfour = true) {

        if(fivefive = true) {

            if(threeseven = true) {

                winner = true;

            }

        }

    }

    if(onesix = true) {

        if(twosix = true) {

            if(threesix = true) {

                winner = true;

            }

        }

    }

    if(twosix = true) {

        if(threesix = true) {

            if(fivesix = true) {

                winner = true;

            }

        }

    }

    if(twosix = true) {

        if(fivesix = true) {

            if(sixsix = true) {

                winner = true;

            }

        }

    }

}

if(fiveone = true) {

    if(twoone = true) {

        if(threeone = true) {

            if(fourone = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fourtwo = true) {

            if(fiveone = true) {

                winner = true;

            }

        }

    }

    if(fivetwo = true) {

        if(fivethree = true) {

            if(fivefour = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(twofive = true) {

            if(threefour = true) {

                winner = true;

            }

        }

    }

}

if(fivetwo = true) {

    if(twofive = true) {

        if(threefour = true) {

            if(fourthree = true) {

                winner = true;

            }

        }

    }

    if(threefour = true) {

        if(fourthree = true) {

            if(sixone = true) {

                winner = true;

            }

        }

    }

    if(fiveone = true) {

        if(fivethree = true) {

            if(fivefour = true) {

                winner = true;

            }

        }

    }

    if(fivethree = true) {

        if(fivefour = true) {

            if(fivefive = true) {

                winner = true;

            }

        }

    }

    if(twotwo = true) {

        if(threetwo = true) {

            if(fourtwo = true) {

                winner = true;

            }

        }

    }

    if(threetwo = true) {

        if(fourtwo = true) {

            if(sixtwo = true) {

                winner = true;

            }

        }

    }

}

if(fivethree = true) {

    if(twosix = true) {

        if(threefive = true) {

            if(fourfour = true) {

                winner = true;

            }

        }

    }

    if(threefive = true) {

        if(fourfour = true) {

            if(sixtwo = true) {

                winner = true;

            }

        }

    }

    if(twothree = true) {

        if(threethree = true) {

            if(fourthree = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fourthree = true) {

            if(sixthree = true) {

                winner = true;

            }

        }

    }

    if(fiveone = true) {

        if(fivetwo = true) {

            if(fivefour = true) {

                winner = true;

            }

        }

    }

    if(fivetwo = true) {

        if(fivefour = true) {

            if(fivefive = true) {

                winner = true;

            }

        }

    }

    if(fivefour = true) {

        if(fivefive = true) {

            if(fivesix = true) {

                winner = true;

            }

        }

    }

}

if(fivefour = true) {

    if(fiveone = true) {

        if(fivetwo = true) {

            if(fivethree = true) {

                winner = true;

            }

        }

    }

    if(fivetwo = true) {

        if(fivethree = true) {

            if(fivefive = true) {

                winner = true;

            }

        }

    }

    if(fivethree = true) {

        if(fivefive = true) {

            if(fivesix = true) {

                winner = true;

            }

        }

    }

    if(fivefive = true) {

        if(fivesix = true) {

            if(fiveseven = true) {

                winner = true;

            }

        }

    }

    if(twoone = true) {

        if(threetwo = true) {

            if(fourthree = true) {

                winner = true;

            }

        }

    }

    if(threetwo = true) {

        if(fourthree = true) {

            if(sixfive = true) {

                winner = true;

            }

        }

    }

    if(twoseven = true) {

        if(threesix = true) {

            if(fourfive = true) {

                winner = true;

            }

        }

    }

    if(threesix = true) {

        if(fourfive = true) {

            if(sixthree = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(threefour = true) {

            if(fourfour = true) {

                winner = true;

            }

        }

    }

    if(threefour = true) {

        if(fourfour = true) {

            if(sixfour = true) {

                winner = true;

            }

        }

    }

}

if(fivefive = true) {

    if(fivetwo = true) {

        if(fivethree = true) {

            if(fivefour = true) {

                winner = true;

            }

        }

    }

    if(fivethree = true) {

        if(fivefour = true) {

            if(fivesix = true) {

                winner = true;

            }

        }

    }

    if(fivefour = true) {

        if(fivesix = true) {

            if(fiveseven = true) {

                winner = true;

            }

        }

    }

    if(twotwo = true) {

        if(threethree = true) {

            if(fourfour = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fourfour = true) {

            if(sixsix = true) {

                winner = true;

            }

        }

    }

    if(twofive = true) {

        if(threefive = true) {

            if(fourfive = true) {

                winner = true;

            }

        }

    }

    if(threefive = true) {

        if(fourfive = true) {

            if(sixfive = true) {

                winner = true;

            }

        }

    }

    if(threeseven = true) {

        if(foursix = true) {

            if(sixfour = true) {

                winner = true;

            }

        }

    }

}

if(fivesix = true) {

    if(twothree = true) {

        if(threefour = true) {

            if(fourfive = true) {

                winner = true;

            }

        }

    }

    if(threefour = true) {

        if(fourfive = true) {

            if(sixseven = true) {

                winner = true;

            }

        }

    }

    if(sixthree = true) {

        if(sixfour = true) {

            if(sixfive = true) {

                winner = true;

            }

        }

    }

    if(sixfour = true) {

        if(sixfive = true) {

            if(sixseven = true) {

                winner = true;

            }

        }

    }

    if(twosix = true) {

        if(threesix = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

    if(threesix = true) {

        if(foursix = true) {

            if(sixsix = true) {

                winner = true;

            }

        }

    }

}

if(fiveseven = true) {

    if(twoseven = true) {

        if(threeseven = true) {

            if(fourseven = true) {

                winner = true;

            }

        }

    }

    if(threeseven = true) {

        if(fourseven = true) {

            if(sixseven = true) {

                winner = true;

            }

        }

    }

    if(twofour = true) {

        if(threefive = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

    if(fivefour = true) {

        if(fivefive = true) {

            if(fivesix = true) {

                winner = true;

            }

        }

    }

}
if(sixone = true) {

    if(threefour = true) {

        if(fourthree = true) {

            if(fivetwo = true) {

                winner = true;

            }

        }

    }

    if(threeone = true) {

        if(fourone = true) {

            if(fiveone = true) {

                winner = true;

            }

        }

    }

    if(twosix = true) {

        if(threesix = true) {

            if(foursix = true) {

                winner = true;

            }

        }

    }

}

if(sixthree = true) {

    if(threesix = true) {

        if(fourfive = true) {

            if(fivefour = true) {

                winner = true;

            }

        }

    }

    if(threethree = true) {

        if(fourthree = true) {

            if(fivethree = true) {

                winner = true;

            }

        }

    }

    if(sixone = true) {

        if(sixtwo = true) {

            if(sixfour = true) {

                winner = true;

            }

        }

    }

    if(sixtwo = true) {

        if(sixfour = true) {

            if(sixfive = true) {

                winner = true;

            }

        }

    }

    if(sixfour = true) {

        if(sixfive = true) {

            if(sixsix = true) {

                winner = true;

            }

        }

    }

}

if(sixfive = true) {

    if(sixtwo = true) {

        if(sixthree = true) {

            if(sixfour = true) {

                winner = true;

            }

        }

    }

    if(sixthree = true) {

        if(sixfour = true) {

            if(sixsix = true) {

                winner = true;

            }

        }

    }

    if(sixfour = true) {

        if(sixsix = true) {

            if(sixseven = true) {

                winner = true;

            }

        }

    }

    if(threefive = true) {

        if(fourfive = true) {

            if(fivefive = true) {

                winner = true;

            }

        }

    }

    if(threetwo = true) {

        if(fourthree = true) {

            if(fivefour = true) {

                winner = true;

            }

        }

    }

}

if(sixseven = true) {

    if(threefour = true) {

        if(fourfive = true) {

            if(fivesix = true) {

                winner = true;

            }

        }

    }

    if(threeseven = true) {

        if(fourseven = true) {

            if(fiveseven = true) {

                winner = true;

            }

        }

    }

    if(sixfour = true) {

        if(sixfive = true) {

            if(sixsix = true) {

                winner = true;

            }

        }

    }

 

            System.out.println("Where would you like to play? (Row 1, 2, 3, etc)");

            String row = scan.next();

            if(row.equals("Row 1")) {

                if(oneone = false) {

                    oneone = true;

                }

                else if(oneone = true) {

                    if(onetwo = false) {

                        onetwo = true;

                }

                else if(onetwo = true) {

                    if(onethree = false) {

                        onethree = true;

                    }

                    else if(onethree = true) {

                        if(onefour = false) {

                            onefour = true;

                        }

                        else if(onefour = true) {

                            if(onefive = false) {

                                onefive = true;

                            }

                            else if(onefive = true) {

                                if(onesix = false) {

                                    onesix = true;

                                }

                                 else if(onesix = true) {

                                     if(oneseven = false) {

                                          oneseven = true;

 

                                }

                            }

                        }

                    }

                }

            }

        }

        else if(row.equals("Row 2")) {

            if(twoone = false) {

                    twoone = true;

                }

                else if(twoone = true) {

                    if(twotwo = false) {

                        twotwo = true;

                }

                else if(twotwo = true) {

                    if(twothree = false) {

                        onethree = true;

                    }

                    else if(twothree = true) {

                        if(twofour = false) {

                            onefour = true;

                        }

                        else if(twofour = true) {

                            if(twofive = false) {

                                onefive = true;

                            }

                            else if(twofive = true) {

                                if(twosix = false) {

                                    twosix = true;

                                }

                                 else if(twosix = true) {

                                     if(twoseven = false) {

                                         twoseven = true;

                                }

                            }

                        }

                    }

                }

            }

        }

        else if(row.equals("Row 3")) {

            if(threeone = false) {

                    oneone = true;

                }

                else if(threeone = true) {

                    if(threetwo = false) {

                        threetwo = true;

                }

                else if(threetwo = true) {

                    if(threethree = false) {

                        threethree = true;

                    }

                    else if(threethree = true) {

                        if(threefour = false) {

                            threefour = true;

                        }

                        else if(threefour = true) {

                            if(threefive = false) {

                                threefive = true;

                            }

                            else if(threefive = true) {

                                if(threesix = false) {

                                    threesix = true;

                                }

                                 else if(threesix = true) {

                                     if(threeseven = false) {

                                         threeseven = true;

                               }

                            }

                        }

                    }

                }

            }

        }

        

        else if(row.equals("Row 4")) {

            if(fourone = false) {

                    fourone = true;

                }

                else if(fourone = true) {

                    if(fourtwo = false) {

                        fourtwo = true;

                }

                else if(fourtwo = true) {

                    if(fourthree = false) {

                        fourthree = true;

                    }

                    else if(fourthree = true) {

                        if(fourfour = false) {

                            fourfour = true;

                        }

                        else if(fourfour = true) {

                            if(fourfive = false) {

                                fourfive = true;

                            }

                            else if(fourfive = true) {

                                if(foursix = false) {

                                    foursix = true;

                                }

                            else if(foursix = true) {

                                if(fourseven = false) {

                                    fourseven = true;

                                   }

                                }

                            }

                        }

                    }

                }

            }

        }

        else if(row.equals("Row 5")) {

            if(fiveone = false) {

                    fiveone = true;

                }

                else if(fiveone = true) {

                    if(fivetwo = false) {

                        fivetwo = true;

                }

                else if(fivetwo = true) {

                    if(fivethree = false) {

                        fivethree = true;

                    }

                    else if(fivethree = true) {

                        if(fivefour = false) {

                            fivefour = true;

                        }

                        else if(fivefour = true) {

                            if(fivefive = false) {

                                fivefive = true;

                            }

                            else if(fivefive = true) {

                                if(fivesix = false) {

                                    fivesix = true;

                                }

                                 else if(fivesix = true) {

                                     if(fiveseven = false) {

                                         fiveseven = true;

 

                            }

                        }

                    }

                }

            }

        }

        else if(row.equals("Row 6")) {

            if(sixone = false) {

                    sixone = true;

                }

                else if(sixone = true) {

                    if(sixtwo = false) {

                        sixtwo = true;

                }

                else if(sixtwo = true) {

                    if(sixthree = false) {

                        sixthree = true;

                    }

                    else if(sixthree = true) {

                        if(sixfour = false) {

                            sixfour = true;

                        }

                        else if(sixfour = true) {

                            if(sixfive = false) {

                                sixfive = true;

                            }

                            else if(sixfive = true) {

                                if(sixsix = false) {

                                    sixsix = true;

                                }

                            else if(sixsix = true) {

                                if(sixseven = false) {

                                    sixseven = true;

                                }

                            }

                        }

                    }

                }

            }

        }

    }

}

}

I'm a TA for a CS class at my school, graded this submission for a connect 4 project, idk wtf happened with this persons thought process tbh.....

By https://coderguy1777.github.io, 2019-08-30 18:09:34

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }

        fileObjectDAO = new FileObjectDAO(this);
        iv = (ImageView)findViewById(R.id.imageView);
        tv = (TextView)findViewById(R.id.textView);
        centerImageView = (ImageButton)findViewById(R.id.imageButton);
        leftText = (TextView)findViewById(R.id.textView2);
        rightText = (TextView)findViewById(R.id.textView3);
        leftArrow = (TextView)findViewById(R.id.textView4);
        rightArrow =  (TextView)findViewById(R.id.textView9);
        leftCancel = (ImageButton)findViewById(R.id.imageButton2);
        displayWelcome1  = (TextView)findViewById(R.id.textView5);
        displayWelcome2  = (TextView)findViewById(R.id.textView6);
        rightCancel = (ImageButton)findViewById(R.id.imageButton3);

        seatButton = (ImageButton)findViewById(R.id.imageButton4);
        waitButton = (ImageButton)findViewById(R.id.imageButton5);
        clearButton = (ImageButton)findViewById(R.id.imageButton6);
        enityButton = (ImageButton)findViewById(R.id.imageButton7);
        bookButton = (ImageButton)findViewById(R.id.imageButton8);
        settingButton = (ImageButton)findViewById(R.id.imageButton9);

        displatSeat = (TextView)findViewById(R.id.textView7);
        displatSeatNumber = (TextView)findViewById(R.id.textView8);
        isClearing = false;
        hidenAll();
        key1 = 0;
        key2 = 0;
        key3 = 0;

        isError = false;
        isWaiting = false;

        myTTS = new TapiaTTS(this);
        myhandler = new Tapiahandler();
        mySTT = new TapiaSTT(this,myhandler,false);
        isResume = false;
        tapiaAnimation = new TapiaAnimation(this);

        liveData.add("愛媛");
        liveData.add("松山");
        liveData.add("今治");
        liveData.add("高知");
        liveData.add("福岡");
        liveData.add("北九州");
        liveData.add("佐賀");
        liveData.add("長崎");
        liveData.add("熊本");
        liveData.add("大分");
        liveData.add("別府");
        liveData.add("宮崎");
        liveData.add("高千穂");
        liveData.add("鹿児島");
        liveData.add("奄美大島");
        liveData.add("屋久島");
        liveData.add("沖縄");
        liveData.add("那覇");
        liveData.add("北海道");
        liveData.add("札幌");
        liveData.add("函館");
        liveData.add("室蘭");
        liveData.add("浦河");
        liveData.add("旭川");
        liveData.add("留萌");
        liveData.add("稚内");
        liveData.add("網走");
        liveData.add("帯広");
        liveData.add("登別");
        liveData.add("知床");
        liveData.add("釧路");
        liveData.add("根室");
        liveData.add("青森");
        liveData.add("岩手");
        liveData.add("盛岡");
        liveData.add("秋田");
        liveData.add("宮城");
        liveData.add("仙台");
        liveData.add("松島");
        liveData.add("泉");
        liveData.add("登米");
        liveData.add("佐沼");
        liveData.add("山形");
        liveData.add("福島");
        liveData.add("郡山");
        liveData.add("茨城");
        liveData.add("水戸");
        liveData.add("栃木");
        liveData.add("日光");
        liveData.add("宇都宮");
        liveData.add("群馬");
        liveData.add("前橋");
        liveData.add("高崎");
        liveData.add("埼玉");
        liveData.add("千葉");
        liveData.add("成田");
        liveData.add("木更津");
        liveData.add("船橋");
        liveData.add("松戸");
        liveData.add("東京");
        liveData.add("銀座");
        liveData.add("浅草");
        liveData.add("池袋");
        liveData.add("上野");
        liveData.add("新宿");
        liveData.add("渋谷");
        liveData.add("品川");
        liveData.add("巣鴨");
        liveData.add("八王子");
        liveData.add("神奈川");
        liveData.add("横浜");
        liveData.add("川崎");
        liveData.add("横須賀");
        liveData.add("相模原");
        liveData.add("山梨");
        liveData.add("甲府");
        liveData.add("新潟");
        liveData.add("佐渡");
        liveData.add("富山");
        liveData.add("石川");
        liveData.add("金沢");
        liveData.add("福井");
        liveData.add("長野");
        liveData.add("軽井沢");
        liveData.add("松本");
        liveData.add("岐阜");
        liveData.add("飛騨高山");
        liveData.add("静岡");
        liveData.add("富士");
        liveData.add("浜松");
        liveData.add("愛知");
        liveData.add("名古屋");
        liveData.add("三重");
        liveData.add("伊勢");
        liveData.add("津");
        liveData.add("滋賀");
        liveData.add("大津");
        liveData.add("京都");
        liveData.add("大阪");
        liveData.add("堺");
        liveData.add("東大阪");
        liveData.add("兵庫");
        liveData.add("神戸");
        liveData.add("姫路");
        liveData.add("奈良");
        liveData.add("和歌山");
        liveData.add("鳥取");
        liveData.add("島根");
        liveData.add("出雲");
        liveData.add("松江");
        liveData.add("岡山");
        liveData.add("広島");
        liveData.add("福山");
        liveData.add("山口");
        liveData.add("下関");
        liveData.add("徳島");
        liveData.add("香川");
        liveData.add("高松");
        try {
            SN = getSerialNumber();
        }catch (Exception e){
            SN = "mji123456";
        }
//
        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread paramThread, Throwable paramThrowable) {
                myHandaling(paramThread, paramThrowable);
            }
        });
        
        
        connectFtp();

        tapiaGet = new TapiaGetJson();
        setWalkpaper();

//        longPressRunnable = new Runnable() {
//            public void run() {
//                if(currentMode.equalsIgnoreCase("talk")){
//                    myTTS.stopSpeak();
//                    mySTT.stop();
//                    checkHandler98_BLUE.removeCallbacks(checkRunnable98_BLUE);
//                    isListen = false;
//                    tapiaAnimation.playColor1(1);
//                    String [] SpeakArray = {"またあとでね", "またね", "あとでね", "ちょっとひとやすみ", "休憩するね"};
//                    Random ran = new Random();
//                    int index = ran.nextInt(SpeakArray.length);
//                    String toSpeak = SpeakArray[index];
//                    //Toast.makeText(getApplicationContext(), toSpeak,Toast.LENGTH_SHORT).show();
//                    myTTS.TapiaSpeak(toSpeak);
//                    //iv.setImageResource(R.drawable.black);
//                    myTTS.player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
//
//                        @Override
//                        public void onCompletion(MediaPlayer mp) {
////                                Intent intent = new Intent(context, StartActivity.class);
////                                startActivity(intent);
//                            count98 =0;
//                            checkStateHander.postDelayed(checkStateRunnable,5000);
//                            handler98.postDelayed(runnable98,800);
//                            setSleepMode();
//                        }
//
//                    });
//                }else if(currentMode.equalsIgnoreCase("sleep")){
//                    setTalkingMode();
//                    checkStateHander.removeCallbacks(checkStateRunnable);
//                    handler98.removeCallbacks(runnable98);
//                    needForHelp("なにかご用ですか?");
//                }
//            }
//        };
//

        createDirIfNotExists("/sdcard/TapiaData/Send/");
        createDirIfNotExists("/sdcard/TapiaData/Receive/");
 public void run() {

                Log.d("Tapia","Check 98");

                if(count98==0){


                    boolean check = false;
                    boolean check2 = false;
                    String path = "/Tapia/"+seatNumber+"/";
                    allFileName = ftpPrintFilesList(path);
                    if(allFileName.size()==0){


                    }else{
                        for(String filename :allFileName){

                            if(filename.endsWith("98.trg")){

                                if(!fileObjectDAO.checkFileExit(filename)){
                                    fileObjectDAO.addFile(filename);
                                    isDelete = true;
                                    check = true;
                                    Log.e("checking","98");
                                    ftpDownload(path + filename, "/sdcard/TapiaData/Receive/" + filename);
                                    break;
                                }
                            }
                        }

                    }

                    if(!check){
                        path = "/Tapia/ALL/";
                        allFileName = ftpPrintFilesList(path);
                        if(allFileName.size()==0){


                        }else{
                            for(String filename :allFileName){

                                if(filename.endsWith("98.trg")){

                                    if(!fileObjectDAO.checkFileExit(filename)){
                                        fileObjectDAO.addFile(filename);
                                        isDelete = true;
                                        check2 = true;
                                        ftpDownload(path+filename,"/sdcard/TapiaData/Receive/"+filename);
                                        break;
                                    }
                                }
                            }

                        }


                    }
                        count98++;
                        handler98.postDelayed(this, 1000);

                }else{
                    count98++;
                    if(count98==10)count98=0;
                    handler98.postDelayed(this, 1000);
                }

            }
        };


Trust me it works!!!

PS. This is 300 out of 3000 lines from one Class

By SIMON WONG , 2018-08-20 10:19:44
        if (!rtrId.isPresent()) {
            ...
        } else if (identityId.isPresent() && rtrId.isPresent()) {
            ...
        }
        

A treasured knife protects

By Dunia, 2018-09-18 10:34:19
    @Override
    public String toString() {
        List<Integer> accountLevels = new ArrayList<>();
        List<String> accountIds = new ArrayList<>();

        for (SelectedHierarchyLevel selectedHierarchyLevel : selectedHierarchyLevels) {
            accountLevels.add(selectedHierarchyLevel.getLevel());
            accountIds.add(selectedHierarchyLevel.getAccountRowId());
        }

        vetoAreValidIds(accountIds);
        StringBuilder converterString = new StringBuilder();

        convert(accountLevels, converterString);
        converterString.append("$");
        convert(accountIds, converterString);

        return converterString.toString();
    }

Just because you can, doesn’t mean you should.

By Anonymous, 2019-04-12 10:55:17
try{
    //...
    getMyDataFromServer();
    //...
}catch(Excepion e){
    // :D
}

HMM FIXED BUG!

By H20, 2017-12-23 11:12:50
public static returnTrue(boolean b){
    if (b){
        return true;
    } else {
        return true;
    }
}

When you want your function always returns the correct value

By kayvan goli, 2017-12-13 14:49:39
private <T> Supplier<T> abort(Class<T> exception) {
  return () -> {
    try {
      return exception.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  };
}

...

throw abort(MyException.class).get();
By Anonymous, 2017-12-14 11:27:50
 Map<Object, List<Element>> groupeUniqueMap =values.stream().collect(Collectors.groupingBy(this::getCompositeGroupKey, Collectors.toList()));
      if(groupeUniqueMap.containsKey(Arrays.asList(null,null,null,null,null,null,null)))
        return values;
      return doReturn();
By ThisIsFine, 2020-07-02 18:41:35
if (responseCode / 100 == 2) {//success
    return handleSuccess();
} else if (responseCode == 401) {
    return handleNotAuthorized();
} else {
    // something else
} 
By Anonymous, 2019-01-29 09:41:13
try {
    synchronized(this) {
        Object obj = null;

        if (obj.hashCode() == -1) {
            obj = new Object();
        }
    }
} catch (Throwable t) {
    throw t;
} finally {
    try {
        synchronized(this) {
            Object obj = null;

            if (obj.hashCode() == -1) {
                obj = new Object();
            }
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        try {
            synchronized(this) {
                Object obj = null;

                if (obj.hashCode() == -1) {
                    obj = new Object();
                }
            }
        } catch (Throwable t) {
            throw t;
        } finally {
            System.exit(1);
        }
    }
}

Cool code

By Conclure, 2020-10-30 02:26:02

"  ".split(" ");

Very weird code found multiple times in old code base.

By heldt, 2017-12-12 12:03:14