package br.com.rogrs.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import br.com.rogrs.model.Endereco;
import br.com.rogrs.service.ViaCEPService;

@RestController
@RequestMapping("/buscar")
public class CEPController {
	
	@Autowired
	private ViaCEPService viaCEPService;

    @RequestMapping("/cep")
    public ResponseEntity<Endereco> buscarCEP(@RequestParam(value="cep") String cep) {
        
    	Endereco endereco =  viaCEPService.buscaCEP(cep);
    	
    	if (null == endereco || endereco.isErro()) {
            throw new ResourceNotFoundException("CEP não encontrado!");
        }
    	
    	
        return new ResponseEntity<>(endereco, HttpStatus.OK);
    }
    @ResponseStatus(value = HttpStatus.NOT_FOUND)
    public class ResourceNotFoundException extends RuntimeException
    {       
        private static final long serialVersionUID = -6252766749487342137L;    
        public ResourceNotFoundException(String message) {
            super(message);
        }    
    }

}
@@ -585,18 +585,17 @@
 oller %7B%0A
-%09
 %0A
+
 %09@Autowi
@@ -637,20 +637,17 @@
 rvice;%0A%0A
-    
+%09
 @Request
@@ -662,20 +662,17 @@
 %22/cep%22)%0A
-    
+%09
 public R
@@ -724,17 +724,19 @@
 am(value
-=
+ = 
 %22cep%22) S
@@ -752,21 +752,10 @@
 ) %7B%0A
-        %0A    
+%0A%09
 %09End
@@ -770,17 +770,16 @@
 dereco =
- 
  viaCEPS
@@ -800,26 +800,18 @@
 P(cep);%0A
-    %09%0A    
+%0A%09
 %09if (nul
@@ -848,28 +848,19 @@
 ro()) %7B%0A
-            
+%09%09%09
 throw ne
@@ -915,38 +915,15 @@
 %22);%0A
-        %7D%0A    %09%0A    %09%0A        
+%09%09%7D%0A%0A%09%09
 retu
@@ -976,18 +976,13 @@
 K);%0A
-    %7D%0A    
+%09%7D%0A%0A%09
 @Res
@@ -1023,20 +1023,17 @@
 _FOUND)%0A
-    
+%09
 public c
@@ -1091,30 +1091,13 @@
 tion
-%0A    %7B       %0A        
+ %7B%0A%09%09
 priv
@@ -1163,21 +1163,12 @@
 37L;
-    %0A        
+%0A%0A%09%09
 publ
@@ -1218,20 +1218,11 @@
 ) %7B%0A
-            
+%09%09%09
 supe
@@ -1237,26 +1237,13 @@
 e);%0A
-        %7D    %0A    
+%09%09%7D%0A%09
 %7D%0A%0A%7D

Ajuste na formatação